
../../vmlinux:     file format elf64-littleriscv


Disassembly of section .text:

ffffffe000200000 <_skernel>:

.section .text.init
.globl _start, _end
_start:

  la sp, boot_stack_top
ffffffe000200000:	00009117          	auipc	sp,0x9
ffffffe000200004:	00010113          	mv	sp,sp
  addi sp, sp, 400
ffffffe000200008:	19010113          	addi	sp,sp,400 # ffffffe000209190 <boot_stack_top+0x190>
  addi sp, sp, 400
ffffffe00020000c:	19010113          	addi	sp,sp,400
  addi sp, sp, 400
ffffffe000200010:	19010113          	addi	sp,sp,400
  addi sp, sp, 400
ffffffe000200014:	19010113          	addi	sp,sp,400
  # li t0, 0xFFFFFFDF80000000
  # sub sp, sp, t0

  call setup_vm
ffffffe000200018:	585000ef          	jal	ra,ffffffe000200d9c <setup_vm>
  call relocate
ffffffe00020001c:	040000ef          	jal	ra,ffffffe00020005c <relocate>

  call mm_init
ffffffe000200020:	570000ef          	jal	ra,ffffffe000200590 <mm_init>
  call setup_vm_final
ffffffe000200024:	601000ef          	jal	ra,ffffffe000200e24 <setup_vm_final>
  call task_init
ffffffe000200028:	5bc000ef          	jal	ra,ffffffe0002005e4 <task_init>
  
  #set stvec = _traps
  la a0, _traps
ffffffe00020002c:	00000517          	auipc	a0,0x0
ffffffe000200030:	06850513          	addi	a0,a0,104 # ffffffe000200094 <_traps>
  csrw stvec, a0
ffffffe000200034:	10551073          	csrw	stvec,a0

  #set sie[STIE] = 1
  li a0, 1 << 5 
ffffffe000200038:	02000513          	li	a0,32
  csrs sie, a0
ffffffe00020003c:	10452073          	csrs	sie,a0

  #set first_time_interupt
  rdtime a0
ffffffe000200040:	c0102573          	rdtime	a0
  li t0, 0x30000
ffffffe000200044:	000302b7          	lui	t0,0x30
  add a0,a0,t0
ffffffe000200048:	00550533          	add	a0,a0,t0
  call sbi_set_timer
ffffffe00020004c:	465000ef          	jal	ra,ffffffe000200cb0 <sbi_set_timer>

  #set sstatus[SIE] = 1
  li a0, 1 << 1
ffffffe000200050:	00200513          	li	a0,2
  csrs sstatus, a0
ffffffe000200054:	10052073          	csrs	sstatus,a0

  j start_kernel
ffffffe000200058:	1700106f          	j	ffffffe0002011c8 <start_kernel>

ffffffe00020005c <relocate>:
    # set sp = sp + PA2VA_OFFSET (If you have set the sp before)

    ###################### 
    #   YOUR CODE HERE   #
    ######################
    li t0, 0xFFFFFFDF80000000
ffffffe00020005c:	fbf0029b          	addiw	t0,zero,-65
ffffffe000200060:	01f29293          	slli	t0,t0,0x1f
    add ra, ra, t0;
ffffffe000200064:	005080b3          	add	ra,ra,t0
    add sp, sp, t0;
ffffffe000200068:	00510133          	add	sp,sp,t0
    # set satp with early_pgtbl

    ###################### 
    #   YOUR CODE HERE   #
    ######################
    la t1, early_pgtbl
ffffffe00020006c:	00005317          	auipc	t1,0x5
ffffffe000200070:	f9430313          	addi	t1,t1,-108 # ffffffe000205000 <early_pgtbl>
    # sub t1, t1, t0
    srli t1, t1, 12
ffffffe000200074:	00c35313          	srli	t1,t1,0xc
    li t2, 8 << 60
ffffffe000200078:	fff0039b          	addiw	t2,zero,-1
ffffffe00020007c:	03f39393          	slli	t2,t2,0x3f
    or t1, t1, t2
ffffffe000200080:	00736333          	or	t1,t1,t2
    csrw satp, t1
ffffffe000200084:	18031073          	csrw	satp,t1

    # flush tlb
    sfence.vma zero, zero
ffffffe000200088:	12000073          	sfence.vma

    # flush icache
    fence.i
ffffffe00020008c:	0000100f          	fence.i

    ret
ffffffe000200090:	00008067          	ret

ffffffe000200094 <_traps>:
    .extern trap_handler
    .globl __dummy
    .global __switch_to
_traps:
    # 1. save 32 registers and sepc to stack-----------
    sd sp,  -8(sp)
ffffffe000200094:	fe213c23          	sd	sp,-8(sp)
    sd ra, -16(sp)
ffffffe000200098:	fe113823          	sd	ra,-16(sp)
    sd gp, -24(sp)
ffffffe00020009c:	fe313423          	sd	gp,-24(sp)
    sd x4, -32(sp)
ffffffe0002000a0:	fe413023          	sd	tp,-32(sp)
    sd t0, -40(sp)
ffffffe0002000a4:	fc513c23          	sd	t0,-40(sp)
    sd t1, -48(sp)
ffffffe0002000a8:	fc613823          	sd	t1,-48(sp)
    sd t2, -56(sp)
ffffffe0002000ac:	fc713423          	sd	t2,-56(sp)
    sd t3, -64(sp)
ffffffe0002000b0:	fdc13023          	sd	t3,-64(sp)
    sd t4, -72(sp)
ffffffe0002000b4:	fbd13c23          	sd	t4,-72(sp)
    sd t5, -80(sp)
ffffffe0002000b8:	fbe13823          	sd	t5,-80(sp)
    sd t6, -88(sp)
ffffffe0002000bc:	fbf13423          	sd	t6,-88(sp)
    sd s0, -96(sp)
ffffffe0002000c0:	fa813023          	sd	s0,-96(sp)
    sd s1, -104(sp)
ffffffe0002000c4:	f8913c23          	sd	s1,-104(sp)
    sd s2, -112(sp)
ffffffe0002000c8:	f9213823          	sd	s2,-112(sp)
    sd s3, -120(sp)
ffffffe0002000cc:	f9313423          	sd	s3,-120(sp)
    sd s4, -128(sp)
ffffffe0002000d0:	f9413023          	sd	s4,-128(sp)
    sd s5, -136(sp)
ffffffe0002000d4:	f7513c23          	sd	s5,-136(sp)
    sd s6, -144(sp)
ffffffe0002000d8:	f7613823          	sd	s6,-144(sp)
    sd s7, -152(sp)
ffffffe0002000dc:	f7713423          	sd	s7,-152(sp)
    sd s8, -160(sp)
ffffffe0002000e0:	f7813023          	sd	s8,-160(sp)
    sd s9, -168(sp)
ffffffe0002000e4:	f5913c23          	sd	s9,-168(sp)
    sd s10,-176(sp)
ffffffe0002000e8:	f5a13823          	sd	s10,-176(sp)
    sd s11,-184(sp)
ffffffe0002000ec:	f5b13423          	sd	s11,-184(sp)
    sd a0, -192(sp)
ffffffe0002000f0:	f4a13023          	sd	a0,-192(sp)
    sd a1, -200(sp)
ffffffe0002000f4:	f2b13c23          	sd	a1,-200(sp)
    sd a2, -208(sp)
ffffffe0002000f8:	f2c13823          	sd	a2,-208(sp)
    sd a3, -216(sp)
ffffffe0002000fc:	f2d13423          	sd	a3,-216(sp)
    sd a4, -224(sp)
ffffffe000200100:	f2e13023          	sd	a4,-224(sp)
    sd a5, -232(sp)
ffffffe000200104:	f0f13c23          	sd	a5,-232(sp)
    sd a6, -240(sp)
ffffffe000200108:	f1013823          	sd	a6,-240(sp)
    sd a7, -248(sp)
ffffffe00020010c:	f1113423          	sd	a7,-248(sp)
    sd fp, -256(sp)
ffffffe000200110:	f0813023          	sd	s0,-256(sp)
    addi sp,sp,-256
ffffffe000200114:	f0010113          	addi	sp,sp,-256

    # 2. call trap_handler-----------
    csrr a0, scause
ffffffe000200118:	14202573          	csrr	a0,scause
    csrr a1, sepc
ffffffe00020011c:	141025f3          	csrr	a1,sepc
    call trap_handler
ffffffe000200120:	3dd000ef          	jal	ra,ffffffe000200cfc <trap_handler>
    
    # 3. restore sepc and 32 registers (x2(sp) should be restore last) from stack-----------
    ld fp,  0(sp)
ffffffe000200124:	00013403          	ld	s0,0(sp)
    ld a7,  8(sp)
ffffffe000200128:	00813883          	ld	a7,8(sp)
    ld a6, 16(sp)
ffffffe00020012c:	01013803          	ld	a6,16(sp)
    ld a5, 24(sp)
ffffffe000200130:	01813783          	ld	a5,24(sp)
    ld a4, 32(sp)
ffffffe000200134:	02013703          	ld	a4,32(sp)
    ld a3, 40(sp)
ffffffe000200138:	02813683          	ld	a3,40(sp)
    ld a2, 48(sp)
ffffffe00020013c:	03013603          	ld	a2,48(sp)
    ld a1, 56(sp)
ffffffe000200140:	03813583          	ld	a1,56(sp)
    ld a0, 64(sp)
ffffffe000200144:	04013503          	ld	a0,64(sp)
    ld s11,72(sp)
ffffffe000200148:	04813d83          	ld	s11,72(sp)
    ld s10,80(sp)
ffffffe00020014c:	05013d03          	ld	s10,80(sp)
    ld s9, 88(sp)
ffffffe000200150:	05813c83          	ld	s9,88(sp)
    ld s8, 96(sp)
ffffffe000200154:	06013c03          	ld	s8,96(sp)
    ld s7, 104(sp)
ffffffe000200158:	06813b83          	ld	s7,104(sp)
    ld s6, 112(sp)
ffffffe00020015c:	07013b03          	ld	s6,112(sp)
    ld s5, 120(sp)
ffffffe000200160:	07813a83          	ld	s5,120(sp)
    ld s4, 128(sp)
ffffffe000200164:	08013a03          	ld	s4,128(sp)
    ld s3, 136(sp)
ffffffe000200168:	08813983          	ld	s3,136(sp)
    ld s2, 144(sp)
ffffffe00020016c:	09013903          	ld	s2,144(sp)
    ld s1, 152(sp)
ffffffe000200170:	09813483          	ld	s1,152(sp)
    ld s0, 160(sp)
ffffffe000200174:	0a013403          	ld	s0,160(sp)
    ld t6, 168(sp)
ffffffe000200178:	0a813f83          	ld	t6,168(sp)
    ld t5, 176(sp)
ffffffe00020017c:	0b013f03          	ld	t5,176(sp)
    ld t4, 184(sp)
ffffffe000200180:	0b813e83          	ld	t4,184(sp)
    ld t3, 192(sp)
ffffffe000200184:	0c013e03          	ld	t3,192(sp)
    ld t2, 200(sp)
ffffffe000200188:	0c813383          	ld	t2,200(sp)
    ld t1, 208(sp)
ffffffe00020018c:	0d013303          	ld	t1,208(sp)
    ld t0, 216(sp)
ffffffe000200190:	0d813283          	ld	t0,216(sp)
    ld x4, 224(sp)
ffffffe000200194:	0e013203          	ld	tp,224(sp)
    ld gp, 232(sp)
ffffffe000200198:	0e813183          	ld	gp,232(sp)
    ld ra, 240(sp)
ffffffe00020019c:	0f013083          	ld	ra,240(sp)
    ld sp, 248(sp)
ffffffe0002001a0:	0f813103          	ld	sp,248(sp)
    # 4. return from trap-----------
    sret
ffffffe0002001a4:	10200073          	sret

ffffffe0002001a8 <__dummy>:
    # -----------
__dummy:
    la a0, dummy
ffffffe0002001a8:	00000517          	auipc	a0,0x0
ffffffe0002001ac:	64050513          	addi	a0,a0,1600 # ffffffe0002007e8 <dummy>
    csrw sepc, a0
ffffffe0002001b0:	14151073          	csrw	sepc,a0
    sret
ffffffe0002001b4:	10200073          	sret

ffffffe0002001b8 <__switch_to>:

__switch_to:
    sd ra, 40(a0)
ffffffe0002001b8:	02153423          	sd	ra,40(a0)
    sd sp, 48(a0)
ffffffe0002001bc:	02253823          	sd	sp,48(a0)
    sd s0, 56(a0)
ffffffe0002001c0:	02853c23          	sd	s0,56(a0)
    sd s1, 64(a0)
ffffffe0002001c4:	04953023          	sd	s1,64(a0)
    sd s2, 72(a0)
ffffffe0002001c8:	05253423          	sd	s2,72(a0)
    sd s3, 80(a0)
ffffffe0002001cc:	05353823          	sd	s3,80(a0)
    sd s4, 88(a0)
ffffffe0002001d0:	05453c23          	sd	s4,88(a0)
    sd s5, 96(a0)
ffffffe0002001d4:	07553023          	sd	s5,96(a0)
    sd s6, 104(a0)
ffffffe0002001d8:	07653423          	sd	s6,104(a0)
    sd s7, 112(a0)
ffffffe0002001dc:	07753823          	sd	s7,112(a0)
    sd s8, 120(a0)
ffffffe0002001e0:	07853c23          	sd	s8,120(a0)
    sd s9, 128(a0)
ffffffe0002001e4:	09953023          	sd	s9,128(a0)
    sd s10, 136(a0)
ffffffe0002001e8:	09a53423          	sd	s10,136(a0)
    sd s11, 144(a0)
ffffffe0002001ec:	09b53823          	sd	s11,144(a0)

    ld ra, 40(a1)
ffffffe0002001f0:	0285b083          	ld	ra,40(a1)
    ld sp, 48(a1)
ffffffe0002001f4:	0305b103          	ld	sp,48(a1)
    ld s0, 56(a1)
ffffffe0002001f8:	0385b403          	ld	s0,56(a1)
    ld s1, 64(a1)
ffffffe0002001fc:	0405b483          	ld	s1,64(a1)
    ld s2, 72(a1)
ffffffe000200200:	0485b903          	ld	s2,72(a1)
    ld s3, 80(a1)
ffffffe000200204:	0505b983          	ld	s3,80(a1)
    ld s4, 88(a1)
ffffffe000200208:	0585ba03          	ld	s4,88(a1)
    ld s5, 96(a1)
ffffffe00020020c:	0605ba83          	ld	s5,96(a1)
    ld s6, 104(a1)
ffffffe000200210:	0685bb03          	ld	s6,104(a1)
    ld s7, 112(a1)
ffffffe000200214:	0705bb83          	ld	s7,112(a1)
    ld s8, 120(a1)
ffffffe000200218:	0785bc03          	ld	s8,120(a1)
    ld s9, 128(a1)
ffffffe00020021c:	0805bc83          	ld	s9,128(a1)
    ld s10, 136(a1)
ffffffe000200220:	0885bd03          	ld	s10,136(a1)
    ld s11, 144(a1)
ffffffe000200224:	0905bd83          	ld	s11,144(a1)

    ret
ffffffe000200228:	00008067          	ret

ffffffe00020022c <get_cycles>:
// clock.c
#include"sbi.h"

unsigned long TIMECLOCK = 0x500000;

unsigned long get_cycles() {
ffffffe00020022c:	fe010113          	addi	sp,sp,-32
ffffffe000200230:	00813c23          	sd	s0,24(sp)
ffffffe000200234:	02010413          	addi	s0,sp,32
    unsigned long ret_val;
    __asm__ volatile(
ffffffe000200238:	c01027f3          	rdtime	a5
ffffffe00020023c:	fef43423          	sd	a5,-24(s0)
        "rdtime %[ret_val]"
        :[ret_val] "=r" (ret_val)
        : : "memory"
    );
    return ret_val;
ffffffe000200240:	fe843783          	ld	a5,-24(s0)
}
ffffffe000200244:	00078513          	mv	a0,a5
ffffffe000200248:	01813403          	ld	s0,24(sp)
ffffffe00020024c:	02010113          	addi	sp,sp,32
ffffffe000200250:	00008067          	ret

ffffffe000200254 <clock_set_next_event>:

void clock_set_next_event() {
ffffffe000200254:	fe010113          	addi	sp,sp,-32
ffffffe000200258:	00113c23          	sd	ra,24(sp)
ffffffe00020025c:	00813823          	sd	s0,16(sp)
ffffffe000200260:	02010413          	addi	s0,sp,32
    unsigned long next_time = get_cycles() + TIMECLOCK;
ffffffe000200264:	fc9ff0ef          	jal	ra,ffffffe00020022c <get_cycles>
ffffffe000200268:	00050713          	mv	a4,a0
ffffffe00020026c:	00003797          	auipc	a5,0x3
ffffffe000200270:	d9478793          	addi	a5,a5,-620 # ffffffe000203000 <TIMECLOCK>
ffffffe000200274:	0007b783          	ld	a5,0(a5)
ffffffe000200278:	00f707b3          	add	a5,a4,a5
ffffffe00020027c:	fef43423          	sd	a5,-24(s0)
    sbi_set_timer(next_time);
ffffffe000200280:	fe843503          	ld	a0,-24(s0)
ffffffe000200284:	22d000ef          	jal	ra,ffffffe000200cb0 <sbi_set_timer>
ffffffe000200288:	00000013          	nop
ffffffe00020028c:	01813083          	ld	ra,24(sp)
ffffffe000200290:	01013403          	ld	s0,16(sp)
ffffffe000200294:	02010113          	addi	sp,sp,32
ffffffe000200298:	00008067          	ret

ffffffe00020029c <int_mod>:
#include"math.h"
int int_mod(unsigned int v1,unsigned int v2){
ffffffe00020029c:	fd010113          	addi	sp,sp,-48
ffffffe0002002a0:	02813423          	sd	s0,40(sp)
ffffffe0002002a4:	03010413          	addi	s0,sp,48
ffffffe0002002a8:	00050793          	mv	a5,a0
ffffffe0002002ac:	00058713          	mv	a4,a1
ffffffe0002002b0:	fcf42e23          	sw	a5,-36(s0)
ffffffe0002002b4:	00070793          	mv	a5,a4
ffffffe0002002b8:	fcf42c23          	sw	a5,-40(s0)
    unsigned long long m1=v1;
ffffffe0002002bc:	fdc46783          	lwu	a5,-36(s0)
ffffffe0002002c0:	fef43423          	sd	a5,-24(s0)
    unsigned long long m2=v2;
ffffffe0002002c4:	fd846783          	lwu	a5,-40(s0)
ffffffe0002002c8:	fef43023          	sd	a5,-32(s0)
    m2<<=31;
ffffffe0002002cc:	fe043783          	ld	a5,-32(s0)
ffffffe0002002d0:	01f79793          	slli	a5,a5,0x1f
ffffffe0002002d4:	fef43023          	sd	a5,-32(s0)
    while(m1>=v2){
ffffffe0002002d8:	02c0006f          	j	ffffffe000200304 <int_mod+0x68>
        if(m2<m1){
ffffffe0002002dc:	fe043703          	ld	a4,-32(s0)
ffffffe0002002e0:	fe843783          	ld	a5,-24(s0)
ffffffe0002002e4:	00f77a63          	bgeu	a4,a5,ffffffe0002002f8 <int_mod+0x5c>
            m1-=m2;
ffffffe0002002e8:	fe843703          	ld	a4,-24(s0)
ffffffe0002002ec:	fe043783          	ld	a5,-32(s0)
ffffffe0002002f0:	40f707b3          	sub	a5,a4,a5
ffffffe0002002f4:	fef43423          	sd	a5,-24(s0)
        }
        m2>>=1;
ffffffe0002002f8:	fe043783          	ld	a5,-32(s0)
ffffffe0002002fc:	0017d793          	srli	a5,a5,0x1
ffffffe000200300:	fef43023          	sd	a5,-32(s0)
    while(m1>=v2){
ffffffe000200304:	fd846783          	lwu	a5,-40(s0)
ffffffe000200308:	fe843703          	ld	a4,-24(s0)
ffffffe00020030c:	fcf778e3          	bgeu	a4,a5,ffffffe0002002dc <int_mod+0x40>
    }
    return m1;
ffffffe000200310:	fe843783          	ld	a5,-24(s0)
ffffffe000200314:	0007879b          	sext.w	a5,a5
}
ffffffe000200318:	00078513          	mv	a0,a5
ffffffe00020031c:	02813403          	ld	s0,40(sp)
ffffffe000200320:	03010113          	addi	sp,sp,48
ffffffe000200324:	00008067          	ret

ffffffe000200328 <int_mul>:

int int_mul(unsigned int v1,unsigned int v2){
ffffffe000200328:	fd010113          	addi	sp,sp,-48
ffffffe00020032c:	02813423          	sd	s0,40(sp)
ffffffe000200330:	03010413          	addi	s0,sp,48
ffffffe000200334:	00050793          	mv	a5,a0
ffffffe000200338:	00058713          	mv	a4,a1
ffffffe00020033c:	fcf42e23          	sw	a5,-36(s0)
ffffffe000200340:	00070793          	mv	a5,a4
ffffffe000200344:	fcf42c23          	sw	a5,-40(s0)
    unsigned long long res=0;
ffffffe000200348:	fe043423          	sd	zero,-24(s0)
    while(v2&&v1){
ffffffe00020034c:	03c0006f          	j	ffffffe000200388 <int_mul+0x60>
        if(v2&1){
ffffffe000200350:	fd842783          	lw	a5,-40(s0)
ffffffe000200354:	0017f793          	andi	a5,a5,1
ffffffe000200358:	0007879b          	sext.w	a5,a5
ffffffe00020035c:	00078a63          	beqz	a5,ffffffe000200370 <int_mul+0x48>
            res+=v1;
ffffffe000200360:	fdc46783          	lwu	a5,-36(s0)
ffffffe000200364:	fe843703          	ld	a4,-24(s0)
ffffffe000200368:	00f707b3          	add	a5,a4,a5
ffffffe00020036c:	fef43423          	sd	a5,-24(s0)
        }
        v2>>=1;
ffffffe000200370:	fd842783          	lw	a5,-40(s0)
ffffffe000200374:	0017d79b          	srliw	a5,a5,0x1
ffffffe000200378:	fcf42c23          	sw	a5,-40(s0)
        v1<<=1;
ffffffe00020037c:	fdc42783          	lw	a5,-36(s0)
ffffffe000200380:	0017979b          	slliw	a5,a5,0x1
ffffffe000200384:	fcf42e23          	sw	a5,-36(s0)
    while(v2&&v1){
ffffffe000200388:	fd842783          	lw	a5,-40(s0)
ffffffe00020038c:	0007879b          	sext.w	a5,a5
ffffffe000200390:	00078863          	beqz	a5,ffffffe0002003a0 <int_mul+0x78>
ffffffe000200394:	fdc42783          	lw	a5,-36(s0)
ffffffe000200398:	0007879b          	sext.w	a5,a5
ffffffe00020039c:	fa079ae3          	bnez	a5,ffffffe000200350 <int_mul+0x28>
    }
    return res;
ffffffe0002003a0:	fe843783          	ld	a5,-24(s0)
ffffffe0002003a4:	0007879b          	sext.w	a5,a5
}
ffffffe0002003a8:	00078513          	mv	a0,a5
ffffffe0002003ac:	02813403          	ld	s0,40(sp)
ffffffe0002003b0:	03010113          	addi	sp,sp,48
ffffffe0002003b4:	00008067          	ret

ffffffe0002003b8 <int_div>:

int int_div(unsigned int v1,unsigned int v2){
ffffffe0002003b8:	fc010113          	addi	sp,sp,-64
ffffffe0002003bc:	02813c23          	sd	s0,56(sp)
ffffffe0002003c0:	04010413          	addi	s0,sp,64
ffffffe0002003c4:	00050793          	mv	a5,a0
ffffffe0002003c8:	00058713          	mv	a4,a1
ffffffe0002003cc:	fcf42623          	sw	a5,-52(s0)
ffffffe0002003d0:	00070793          	mv	a5,a4
ffffffe0002003d4:	fcf42423          	sw	a5,-56(s0)
    unsigned long long m1=v1;
ffffffe0002003d8:	fcc46783          	lwu	a5,-52(s0)
ffffffe0002003dc:	fef43423          	sd	a5,-24(s0)
    unsigned long long m2=v2;
ffffffe0002003e0:	fc846783          	lwu	a5,-56(s0)
ffffffe0002003e4:	fef43023          	sd	a5,-32(s0)
    unsigned long long mask=(unsigned int)1<<31;
ffffffe0002003e8:	00100793          	li	a5,1
ffffffe0002003ec:	01f79793          	slli	a5,a5,0x1f
ffffffe0002003f0:	fcf43c23          	sd	a5,-40(s0)
    m2<<=31;
ffffffe0002003f4:	fe043783          	ld	a5,-32(s0)
ffffffe0002003f8:	01f79793          	slli	a5,a5,0x1f
ffffffe0002003fc:	fef43023          	sd	a5,-32(s0)
    unsigned long long res=0;
ffffffe000200400:	fc043823          	sd	zero,-48(s0)
    while(m1>=v2){
ffffffe000200404:	0480006f          	j	ffffffe00020044c <int_div+0x94>
        if(m2<m1){
ffffffe000200408:	fe043703          	ld	a4,-32(s0)
ffffffe00020040c:	fe843783          	ld	a5,-24(s0)
ffffffe000200410:	02f77263          	bgeu	a4,a5,ffffffe000200434 <int_div+0x7c>
            m1-=m2;
ffffffe000200414:	fe843703          	ld	a4,-24(s0)
ffffffe000200418:	fe043783          	ld	a5,-32(s0)
ffffffe00020041c:	40f707b3          	sub	a5,a4,a5
ffffffe000200420:	fef43423          	sd	a5,-24(s0)
            res|=mask;
ffffffe000200424:	fd043703          	ld	a4,-48(s0)
ffffffe000200428:	fd843783          	ld	a5,-40(s0)
ffffffe00020042c:	00f767b3          	or	a5,a4,a5
ffffffe000200430:	fcf43823          	sd	a5,-48(s0)
        }
        m2>>=1;
ffffffe000200434:	fe043783          	ld	a5,-32(s0)
ffffffe000200438:	0017d793          	srli	a5,a5,0x1
ffffffe00020043c:	fef43023          	sd	a5,-32(s0)
        mask>>=1;
ffffffe000200440:	fd843783          	ld	a5,-40(s0)
ffffffe000200444:	0017d793          	srli	a5,a5,0x1
ffffffe000200448:	fcf43c23          	sd	a5,-40(s0)
    while(m1>=v2){
ffffffe00020044c:	fc846783          	lwu	a5,-56(s0)
ffffffe000200450:	fe843703          	ld	a4,-24(s0)
ffffffe000200454:	faf77ae3          	bgeu	a4,a5,ffffffe000200408 <int_div+0x50>
    }
    return res;
ffffffe000200458:	fd043783          	ld	a5,-48(s0)
ffffffe00020045c:	0007879b          	sext.w	a5,a5
ffffffe000200460:	00078513          	mv	a0,a5
ffffffe000200464:	03813403          	ld	s0,56(sp)
ffffffe000200468:	04010113          	addi	sp,sp,64
ffffffe00020046c:	00008067          	ret

ffffffe000200470 <kalloc>:

struct {
    struct run *freelist;
} kmem;

uint64 kalloc() {
ffffffe000200470:	fe010113          	addi	sp,sp,-32
ffffffe000200474:	00813c23          	sd	s0,24(sp)
ffffffe000200478:	02010413          	addi	s0,sp,32
    struct run *r;

    r = kmem.freelist;
ffffffe00020047c:	00004797          	auipc	a5,0x4
ffffffe000200480:	b8478793          	addi	a5,a5,-1148 # ffffffe000204000 <kmem>
ffffffe000200484:	0007b783          	ld	a5,0(a5)
ffffffe000200488:	fef43423          	sd	a5,-24(s0)
    kmem.freelist = r->next;
ffffffe00020048c:	fe843783          	ld	a5,-24(s0)
ffffffe000200490:	0007b703          	ld	a4,0(a5)
ffffffe000200494:	00004797          	auipc	a5,0x4
ffffffe000200498:	b6c78793          	addi	a5,a5,-1172 # ffffffe000204000 <kmem>
ffffffe00020049c:	00e7b023          	sd	a4,0(a5)
    
    //memset((void *)r, 0x0, PGSIZE);
    return (uint64) r;
ffffffe0002004a0:	fe843783          	ld	a5,-24(s0)
}
ffffffe0002004a4:	00078513          	mv	a0,a5
ffffffe0002004a8:	01813403          	ld	s0,24(sp)
ffffffe0002004ac:	02010113          	addi	sp,sp,32
ffffffe0002004b0:	00008067          	ret

ffffffe0002004b4 <kfree>:

void kfree(uint64 addr) {
ffffffe0002004b4:	fd010113          	addi	sp,sp,-48
ffffffe0002004b8:	02813423          	sd	s0,40(sp)
ffffffe0002004bc:	03010413          	addi	s0,sp,48
ffffffe0002004c0:	fca43c23          	sd	a0,-40(s0)
    struct run *r;

    // PGSIZE align 
    addr = addr & ~(PGSIZE - 1);
ffffffe0002004c4:	fd843703          	ld	a4,-40(s0)
ffffffe0002004c8:	fffff7b7          	lui	a5,0xfffff
ffffffe0002004cc:	00f777b3          	and	a5,a4,a5
ffffffe0002004d0:	fcf43c23          	sd	a5,-40(s0)

    // memset((void *)addr, 0x0, (uint64)PGSIZE);

    r = (struct run *)addr;
ffffffe0002004d4:	fd843783          	ld	a5,-40(s0)
ffffffe0002004d8:	fef43423          	sd	a5,-24(s0)
    r->next = kmem.freelist;
ffffffe0002004dc:	00004797          	auipc	a5,0x4
ffffffe0002004e0:	b2478793          	addi	a5,a5,-1244 # ffffffe000204000 <kmem>
ffffffe0002004e4:	0007b703          	ld	a4,0(a5)
ffffffe0002004e8:	fe843783          	ld	a5,-24(s0)
ffffffe0002004ec:	00e7b023          	sd	a4,0(a5)
    kmem.freelist = r;
ffffffe0002004f0:	00004797          	auipc	a5,0x4
ffffffe0002004f4:	b1078793          	addi	a5,a5,-1264 # ffffffe000204000 <kmem>
ffffffe0002004f8:	fe843703          	ld	a4,-24(s0)
ffffffe0002004fc:	00e7b023          	sd	a4,0(a5)

    return ;
ffffffe000200500:	00000013          	nop
}
ffffffe000200504:	02813403          	ld	s0,40(sp)
ffffffe000200508:	03010113          	addi	sp,sp,48
ffffffe00020050c:	00008067          	ret

ffffffe000200510 <kfreerange>:

void kfreerange(char *start, char *end) {
ffffffe000200510:	fd010113          	addi	sp,sp,-48
ffffffe000200514:	02113423          	sd	ra,40(sp)
ffffffe000200518:	02813023          	sd	s0,32(sp)
ffffffe00020051c:	03010413          	addi	s0,sp,48
ffffffe000200520:	fca43c23          	sd	a0,-40(s0)
ffffffe000200524:	fcb43823          	sd	a1,-48(s0)
    char *addr = (char *)PGROUNDUP((uint64)start);
ffffffe000200528:	fd843703          	ld	a4,-40(s0)
ffffffe00020052c:	000017b7          	lui	a5,0x1
ffffffe000200530:	fff78793          	addi	a5,a5,-1 # fff <_skernel-0xffffffe0001ff001>
ffffffe000200534:	00f70733          	add	a4,a4,a5
ffffffe000200538:	fffff7b7          	lui	a5,0xfffff
ffffffe00020053c:	00f777b3          	and	a5,a4,a5
ffffffe000200540:	fef43423          	sd	a5,-24(s0)
    for (; (uint64)(addr) + PGSIZE <= (uint64)end; addr += PGSIZE) {
ffffffe000200544:	0200006f          	j	ffffffe000200564 <kfreerange+0x54>
        kfree((uint64)addr);
ffffffe000200548:	fe843783          	ld	a5,-24(s0)
ffffffe00020054c:	00078513          	mv	a0,a5
ffffffe000200550:	f65ff0ef          	jal	ra,ffffffe0002004b4 <kfree>
    for (; (uint64)(addr) + PGSIZE <= (uint64)end; addr += PGSIZE) {
ffffffe000200554:	fe843703          	ld	a4,-24(s0)
ffffffe000200558:	000017b7          	lui	a5,0x1
ffffffe00020055c:	00f707b3          	add	a5,a4,a5
ffffffe000200560:	fef43423          	sd	a5,-24(s0)
ffffffe000200564:	fe843703          	ld	a4,-24(s0)
ffffffe000200568:	000017b7          	lui	a5,0x1
ffffffe00020056c:	00f70733          	add	a4,a4,a5
ffffffe000200570:	fd043783          	ld	a5,-48(s0)
ffffffe000200574:	fce7fae3          	bgeu	a5,a4,ffffffe000200548 <kfreerange+0x38>
    }
}
ffffffe000200578:	00000013          	nop
ffffffe00020057c:	00000013          	nop
ffffffe000200580:	02813083          	ld	ra,40(sp)
ffffffe000200584:	02013403          	ld	s0,32(sp)
ffffffe000200588:	03010113          	addi	sp,sp,48
ffffffe00020058c:	00008067          	ret

ffffffe000200590 <mm_init>:

void mm_init(void) {
ffffffe000200590:	ff010113          	addi	sp,sp,-16
ffffffe000200594:	00113423          	sd	ra,8(sp)
ffffffe000200598:	00813023          	sd	s0,0(sp)
ffffffe00020059c:	01010413          	addi	s0,sp,16
    printk("in mm\n");
ffffffe0002005a0:	00002517          	auipc	a0,0x2
ffffffe0002005a4:	a6050513          	addi	a0,a0,-1440 # ffffffe000202000 <_srodata>
ffffffe0002005a8:	188010ef          	jal	ra,ffffffe000201730 <printk>
    kfreerange(_ekernel, (char *)PHY_END + PA2VA_OFFSET);
ffffffe0002005ac:	ffe007b7          	lui	a5,0xffe00
ffffffe0002005b0:	02178793          	addi	a5,a5,33 # ffffffffffe00021 <_estack+0x1fffbf6021>
ffffffe0002005b4:	01079593          	slli	a1,a5,0x10
ffffffe0002005b8:	00008517          	auipc	a0,0x8
ffffffe0002005bc:	a4850513          	addi	a0,a0,-1464 # ffffffe000208000 <_ekernel>
ffffffe0002005c0:	f51ff0ef          	jal	ra,ffffffe000200510 <kfreerange>
    printk("mm_init\n");
ffffffe0002005c4:	00002517          	auipc	a0,0x2
ffffffe0002005c8:	a4450513          	addi	a0,a0,-1468 # ffffffe000202008 <_srodata+0x8>
ffffffe0002005cc:	164010ef          	jal	ra,ffffffe000201730 <printk>
}
ffffffe0002005d0:	00000013          	nop
ffffffe0002005d4:	00813083          	ld	ra,8(sp)
ffffffe0002005d8:	00013403          	ld	s0,0(sp)
ffffffe0002005dc:	01010113          	addi	sp,sp,16
ffffffe0002005e0:	00008067          	ret

ffffffe0002005e4 <task_init>:

struct task_struct* idle;           // idle process
struct task_struct* current;        // 指向当前运行线程的 `task_struct`
struct task_struct* task[NR_TASKS]; // 线程数组，所有的线程都保存在此

void task_init() {
ffffffe0002005e4:	fe010113          	addi	sp,sp,-32
ffffffe0002005e8:	00113c23          	sd	ra,24(sp)
ffffffe0002005ec:	00813823          	sd	s0,16(sp)
ffffffe0002005f0:	02010413          	addi	s0,sp,32
    idle = (struct task_struct*)kalloc();
ffffffe0002005f4:	e7dff0ef          	jal	ra,ffffffe000200470 <kalloc>
ffffffe0002005f8:	00050793          	mv	a5,a0
ffffffe0002005fc:	00078713          	mv	a4,a5
ffffffe000200600:	00004797          	auipc	a5,0x4
ffffffe000200604:	a0878793          	addi	a5,a5,-1528 # ffffffe000204008 <idle>
ffffffe000200608:	00e7b023          	sd	a4,0(a5)
    idle->state = TASK_RUNNING;
ffffffe00020060c:	00004797          	auipc	a5,0x4
ffffffe000200610:	9fc78793          	addi	a5,a5,-1540 # ffffffe000204008 <idle>
ffffffe000200614:	0007b783          	ld	a5,0(a5)
ffffffe000200618:	0007b423          	sd	zero,8(a5)
    idle->counter = 0;
ffffffe00020061c:	00004797          	auipc	a5,0x4
ffffffe000200620:	9ec78793          	addi	a5,a5,-1556 # ffffffe000204008 <idle>
ffffffe000200624:	0007b783          	ld	a5,0(a5)
ffffffe000200628:	0007b823          	sd	zero,16(a5)
    idle->priority = 0;
ffffffe00020062c:	00004797          	auipc	a5,0x4
ffffffe000200630:	9dc78793          	addi	a5,a5,-1572 # ffffffe000204008 <idle>
ffffffe000200634:	0007b783          	ld	a5,0(a5)
ffffffe000200638:	0007bc23          	sd	zero,24(a5)
    idle->pid = 0;
ffffffe00020063c:	00004797          	auipc	a5,0x4
ffffffe000200640:	9cc78793          	addi	a5,a5,-1588 # ffffffe000204008 <idle>
ffffffe000200644:	0007b783          	ld	a5,0(a5)
ffffffe000200648:	0207b023          	sd	zero,32(a5)
    current = idle;
ffffffe00020064c:	00004797          	auipc	a5,0x4
ffffffe000200650:	9bc78793          	addi	a5,a5,-1604 # ffffffe000204008 <idle>
ffffffe000200654:	0007b703          	ld	a4,0(a5)
ffffffe000200658:	00004797          	auipc	a5,0x4
ffffffe00020065c:	9b878793          	addi	a5,a5,-1608 # ffffffe000204010 <current>
ffffffe000200660:	00e7b023          	sd	a4,0(a5)
    task[0] = idle;
ffffffe000200664:	00004797          	auipc	a5,0x4
ffffffe000200668:	9a478793          	addi	a5,a5,-1628 # ffffffe000204008 <idle>
ffffffe00020066c:	0007b703          	ld	a4,0(a5)
ffffffe000200670:	00004797          	auipc	a5,0x4
ffffffe000200674:	9b878793          	addi	a5,a5,-1608 # ffffffe000204028 <task>
ffffffe000200678:	00e7b023          	sd	a4,0(a5)

    for(int i = 1;i < NR_TASKS;i ++){
ffffffe00020067c:	00100793          	li	a5,1
ffffffe000200680:	fef42623          	sw	a5,-20(s0)
ffffffe000200684:	1340006f          	j	ffffffe0002007b8 <task_init+0x1d4>
        task[i] = (struct task_struct*)kalloc();
ffffffe000200688:	de9ff0ef          	jal	ra,ffffffe000200470 <kalloc>
ffffffe00020068c:	00050793          	mv	a5,a0
ffffffe000200690:	00078693          	mv	a3,a5
ffffffe000200694:	00004717          	auipc	a4,0x4
ffffffe000200698:	99470713          	addi	a4,a4,-1644 # ffffffe000204028 <task>
ffffffe00020069c:	fec42783          	lw	a5,-20(s0)
ffffffe0002006a0:	00379793          	slli	a5,a5,0x3
ffffffe0002006a4:	00f707b3          	add	a5,a4,a5
ffffffe0002006a8:	00d7b023          	sd	a3,0(a5)
        task[i]->state = TASK_RUNNING;
ffffffe0002006ac:	00004717          	auipc	a4,0x4
ffffffe0002006b0:	97c70713          	addi	a4,a4,-1668 # ffffffe000204028 <task>
ffffffe0002006b4:	fec42783          	lw	a5,-20(s0)
ffffffe0002006b8:	00379793          	slli	a5,a5,0x3
ffffffe0002006bc:	00f707b3          	add	a5,a4,a5
ffffffe0002006c0:	0007b783          	ld	a5,0(a5)
ffffffe0002006c4:	0007b423          	sd	zero,8(a5)
        task[i]->counter = 0;
ffffffe0002006c8:	00004717          	auipc	a4,0x4
ffffffe0002006cc:	96070713          	addi	a4,a4,-1696 # ffffffe000204028 <task>
ffffffe0002006d0:	fec42783          	lw	a5,-20(s0)
ffffffe0002006d4:	00379793          	slli	a5,a5,0x3
ffffffe0002006d8:	00f707b3          	add	a5,a4,a5
ffffffe0002006dc:	0007b783          	ld	a5,0(a5)
ffffffe0002006e0:	0007b823          	sd	zero,16(a5)
        task[i]->priority = int_mod(rand(),PRIORITY_MAX - PRIORITY_MIN + 1) + PRIORITY_MIN;
ffffffe0002006e4:	0cc010ef          	jal	ra,ffffffe0002017b0 <rand>
ffffffe0002006e8:	00050793          	mv	a5,a0
ffffffe0002006ec:	0007879b          	sext.w	a5,a5
ffffffe0002006f0:	00500593          	li	a1,5
ffffffe0002006f4:	00078513          	mv	a0,a5
ffffffe0002006f8:	ba5ff0ef          	jal	ra,ffffffe00020029c <int_mod>
ffffffe0002006fc:	00050793          	mv	a5,a0
ffffffe000200700:	0017879b          	addiw	a5,a5,1
ffffffe000200704:	0007869b          	sext.w	a3,a5
ffffffe000200708:	00004717          	auipc	a4,0x4
ffffffe00020070c:	92070713          	addi	a4,a4,-1760 # ffffffe000204028 <task>
ffffffe000200710:	fec42783          	lw	a5,-20(s0)
ffffffe000200714:	00379793          	slli	a5,a5,0x3
ffffffe000200718:	00f707b3          	add	a5,a4,a5
ffffffe00020071c:	0007b783          	ld	a5,0(a5)
ffffffe000200720:	00068713          	mv	a4,a3
ffffffe000200724:	00e7bc23          	sd	a4,24(a5)
        task[i]->pid = i;
ffffffe000200728:	00004717          	auipc	a4,0x4
ffffffe00020072c:	90070713          	addi	a4,a4,-1792 # ffffffe000204028 <task>
ffffffe000200730:	fec42783          	lw	a5,-20(s0)
ffffffe000200734:	00379793          	slli	a5,a5,0x3
ffffffe000200738:	00f707b3          	add	a5,a4,a5
ffffffe00020073c:	0007b783          	ld	a5,0(a5)
ffffffe000200740:	fec42703          	lw	a4,-20(s0)
ffffffe000200744:	02e7b023          	sd	a4,32(a5)
        task[i]->thread.ra = (uint64)__dummy;
ffffffe000200748:	00004717          	auipc	a4,0x4
ffffffe00020074c:	8e070713          	addi	a4,a4,-1824 # ffffffe000204028 <task>
ffffffe000200750:	fec42783          	lw	a5,-20(s0)
ffffffe000200754:	00379793          	slli	a5,a5,0x3
ffffffe000200758:	00f707b3          	add	a5,a4,a5
ffffffe00020075c:	0007b783          	ld	a5,0(a5)
ffffffe000200760:	00000717          	auipc	a4,0x0
ffffffe000200764:	a4870713          	addi	a4,a4,-1464 # ffffffe0002001a8 <__dummy>
ffffffe000200768:	02e7b423          	sd	a4,40(a5)
        task[i]->thread.sp = (uint64)task[i] + PGSIZE;
ffffffe00020076c:	00004717          	auipc	a4,0x4
ffffffe000200770:	8bc70713          	addi	a4,a4,-1860 # ffffffe000204028 <task>
ffffffe000200774:	fec42783          	lw	a5,-20(s0)
ffffffe000200778:	00379793          	slli	a5,a5,0x3
ffffffe00020077c:	00f707b3          	add	a5,a4,a5
ffffffe000200780:	0007b783          	ld	a5,0(a5)
ffffffe000200784:	00078693          	mv	a3,a5
ffffffe000200788:	00004717          	auipc	a4,0x4
ffffffe00020078c:	8a070713          	addi	a4,a4,-1888 # ffffffe000204028 <task>
ffffffe000200790:	fec42783          	lw	a5,-20(s0)
ffffffe000200794:	00379793          	slli	a5,a5,0x3
ffffffe000200798:	00f707b3          	add	a5,a4,a5
ffffffe00020079c:	0007b783          	ld	a5,0(a5)
ffffffe0002007a0:	00001737          	lui	a4,0x1
ffffffe0002007a4:	00e68733          	add	a4,a3,a4
ffffffe0002007a8:	02e7b823          	sd	a4,48(a5)
    for(int i = 1;i < NR_TASKS;i ++){
ffffffe0002007ac:	fec42783          	lw	a5,-20(s0)
ffffffe0002007b0:	0017879b          	addiw	a5,a5,1
ffffffe0002007b4:	fef42623          	sw	a5,-20(s0)
ffffffe0002007b8:	fec42783          	lw	a5,-20(s0)
ffffffe0002007bc:	0007871b          	sext.w	a4,a5
ffffffe0002007c0:	00300793          	li	a5,3
ffffffe0002007c4:	ece7d2e3          	bge	a5,a4,ffffffe000200688 <task_init+0xa4>
    }
  
    printk("proc_init\n");
ffffffe0002007c8:	00002517          	auipc	a0,0x2
ffffffe0002007cc:	85050513          	addi	a0,a0,-1968 # ffffffe000202018 <_srodata+0x18>
ffffffe0002007d0:	761000ef          	jal	ra,ffffffe000201730 <printk>
}
ffffffe0002007d4:	00000013          	nop
ffffffe0002007d8:	01813083          	ld	ra,24(sp)
ffffffe0002007dc:	01013403          	ld	s0,16(sp)
ffffffe0002007e0:	02010113          	addi	sp,sp,32
ffffffe0002007e4:	00008067          	ret

ffffffe0002007e8 <dummy>:

void dummy() {
ffffffe0002007e8:	fd010113          	addi	sp,sp,-48
ffffffe0002007ec:	02113423          	sd	ra,40(sp)
ffffffe0002007f0:	02813023          	sd	s0,32(sp)
ffffffe0002007f4:	03010413          	addi	s0,sp,48
    uint64 MOD = 1000000007;
ffffffe0002007f8:	3b9ad7b7          	lui	a5,0x3b9ad
ffffffe0002007fc:	a0778793          	addi	a5,a5,-1529 # 3b9aca07 <_skernel-0xffffffdfc48535f9>
ffffffe000200800:	fcf43c23          	sd	a5,-40(s0)
    uint64 auto_inc_local_var = 0;
ffffffe000200804:	fe043423          	sd	zero,-24(s0)
    int last_counter = -1; // 记录上一个counter
ffffffe000200808:	fff00793          	li	a5,-1
ffffffe00020080c:	fef42223          	sw	a5,-28(s0)
    int last_last_counter = -1; // 记录上上个counter
ffffffe000200810:	fff00793          	li	a5,-1
ffffffe000200814:	fef42023          	sw	a5,-32(s0)
    while(1) {
        if (last_counter == -1 || current->counter != last_counter) {
ffffffe000200818:	fe442783          	lw	a5,-28(s0)
ffffffe00020081c:	0007871b          	sext.w	a4,a5
ffffffe000200820:	fff00793          	li	a5,-1
ffffffe000200824:	00f70e63          	beq	a4,a5,ffffffe000200840 <dummy+0x58>
ffffffe000200828:	00003797          	auipc	a5,0x3
ffffffe00020082c:	7e878793          	addi	a5,a5,2024 # ffffffe000204010 <current>
ffffffe000200830:	0007b783          	ld	a5,0(a5)
ffffffe000200834:	0107b703          	ld	a4,16(a5)
ffffffe000200838:	fe442783          	lw	a5,-28(s0)
ffffffe00020083c:	06f70a63          	beq	a4,a5,ffffffe0002008b0 <dummy+0xc8>
            last_last_counter = last_counter;
ffffffe000200840:	fe442783          	lw	a5,-28(s0)
ffffffe000200844:	fef42023          	sw	a5,-32(s0)
            last_counter = current->counter;
ffffffe000200848:	00003797          	auipc	a5,0x3
ffffffe00020084c:	7c878793          	addi	a5,a5,1992 # ffffffe000204010 <current>
ffffffe000200850:	0007b783          	ld	a5,0(a5)
ffffffe000200854:	0107b783          	ld	a5,16(a5)
ffffffe000200858:	fef42223          	sw	a5,-28(s0)
            auto_inc_local_var = int_mod(auto_inc_local_var + 1,MOD);
ffffffe00020085c:	fe843783          	ld	a5,-24(s0)
ffffffe000200860:	0007879b          	sext.w	a5,a5
ffffffe000200864:	0017879b          	addiw	a5,a5,1
ffffffe000200868:	0007879b          	sext.w	a5,a5
ffffffe00020086c:	fd843703          	ld	a4,-40(s0)
ffffffe000200870:	0007071b          	sext.w	a4,a4
ffffffe000200874:	00070593          	mv	a1,a4
ffffffe000200878:	00078513          	mv	a0,a5
ffffffe00020087c:	a21ff0ef          	jal	ra,ffffffe00020029c <int_mod>
ffffffe000200880:	00050793          	mv	a5,a0
ffffffe000200884:	fef43423          	sd	a5,-24(s0)
            printk("[PID = %d]. auto_inc_local_var = %d\n", current->pid, auto_inc_local_var);
ffffffe000200888:	00003797          	auipc	a5,0x3
ffffffe00020088c:	78878793          	addi	a5,a5,1928 # ffffffe000204010 <current>
ffffffe000200890:	0007b783          	ld	a5,0(a5)
ffffffe000200894:	0207b783          	ld	a5,32(a5)
ffffffe000200898:	fe843603          	ld	a2,-24(s0)
ffffffe00020089c:	00078593          	mv	a1,a5
ffffffe0002008a0:	00001517          	auipc	a0,0x1
ffffffe0002008a4:	78850513          	addi	a0,a0,1928 # ffffffe000202028 <_srodata+0x28>
ffffffe0002008a8:	689000ef          	jal	ra,ffffffe000201730 <printk>
ffffffe0002008ac:	0440006f          	j	ffffffe0002008f0 <dummy+0x108>
        } else if((last_last_counter == 0 || last_last_counter == -1) && last_counter == 1) { // counter恒为1的情况
ffffffe0002008b0:	fe042783          	lw	a5,-32(s0)
ffffffe0002008b4:	0007879b          	sext.w	a5,a5
ffffffe0002008b8:	00078a63          	beqz	a5,ffffffe0002008cc <dummy+0xe4>
ffffffe0002008bc:	fe042783          	lw	a5,-32(s0)
ffffffe0002008c0:	0007871b          	sext.w	a4,a5
ffffffe0002008c4:	fff00793          	li	a5,-1
ffffffe0002008c8:	f4f718e3          	bne	a4,a5,ffffffe000200818 <dummy+0x30>
ffffffe0002008cc:	fe442783          	lw	a5,-28(s0)
ffffffe0002008d0:	0007871b          	sext.w	a4,a5
ffffffe0002008d4:	00100793          	li	a5,1
ffffffe0002008d8:	f4f710e3          	bne	a4,a5,ffffffe000200818 <dummy+0x30>
            // 这里比较 tricky，不要求理解。
            last_counter = 0;
ffffffe0002008dc:	fe042223          	sw	zero,-28(s0)
            current->counter = 0;
ffffffe0002008e0:	00003797          	auipc	a5,0x3
ffffffe0002008e4:	73078793          	addi	a5,a5,1840 # ffffffe000204010 <current>
ffffffe0002008e8:	0007b783          	ld	a5,0(a5)
ffffffe0002008ec:	0007b823          	sd	zero,16(a5)
        if (last_counter == -1 || current->counter != last_counter) {
ffffffe0002008f0:	f29ff06f          	j	ffffffe000200818 <dummy+0x30>

ffffffe0002008f4 <switch_to>:
    }
}

extern void __switch_to(struct task_struct* prev, struct task_struct* next);

void switch_to(struct task_struct* next) {
ffffffe0002008f4:	fd010113          	addi	sp,sp,-48
ffffffe0002008f8:	02113423          	sd	ra,40(sp)
ffffffe0002008fc:	02813023          	sd	s0,32(sp)
ffffffe000200900:	03010413          	addi	s0,sp,48
ffffffe000200904:	fca43c23          	sd	a0,-40(s0)
    if(next != current){
ffffffe000200908:	00003797          	auipc	a5,0x3
ffffffe00020090c:	70878793          	addi	a5,a5,1800 # ffffffe000204010 <current>
ffffffe000200910:	0007b783          	ld	a5,0(a5)
ffffffe000200914:	fd843703          	ld	a4,-40(s0)
ffffffe000200918:	04f70e63          	beq	a4,a5,ffffffe000200974 <switch_to+0x80>
        printk("switch to [PID %d, PRIO %d, CNT %d]\n", next->pid, next->priority, next->counter);
ffffffe00020091c:	fd843783          	ld	a5,-40(s0)
ffffffe000200920:	0207b703          	ld	a4,32(a5)
ffffffe000200924:	fd843783          	ld	a5,-40(s0)
ffffffe000200928:	0187b603          	ld	a2,24(a5)
ffffffe00020092c:	fd843783          	ld	a5,-40(s0)
ffffffe000200930:	0107b783          	ld	a5,16(a5)
ffffffe000200934:	00078693          	mv	a3,a5
ffffffe000200938:	00070593          	mv	a1,a4
ffffffe00020093c:	00001517          	auipc	a0,0x1
ffffffe000200940:	71450513          	addi	a0,a0,1812 # ffffffe000202050 <_srodata+0x50>
ffffffe000200944:	5ed000ef          	jal	ra,ffffffe000201730 <printk>
        struct task_struct* prev = current;
ffffffe000200948:	00003797          	auipc	a5,0x3
ffffffe00020094c:	6c878793          	addi	a5,a5,1736 # ffffffe000204010 <current>
ffffffe000200950:	0007b783          	ld	a5,0(a5)
ffffffe000200954:	fef43423          	sd	a5,-24(s0)
        current = next;
ffffffe000200958:	00003797          	auipc	a5,0x3
ffffffe00020095c:	6b878793          	addi	a5,a5,1720 # ffffffe000204010 <current>
ffffffe000200960:	fd843703          	ld	a4,-40(s0)
ffffffe000200964:	00e7b023          	sd	a4,0(a5)
        __switch_to(prev,next);
ffffffe000200968:	fd843583          	ld	a1,-40(s0)
ffffffe00020096c:	fe843503          	ld	a0,-24(s0)
ffffffe000200970:	849ff0ef          	jal	ra,ffffffe0002001b8 <__switch_to>
    }
}
ffffffe000200974:	00000013          	nop
ffffffe000200978:	02813083          	ld	ra,40(sp)
ffffffe00020097c:	02013403          	ld	s0,32(sp)
ffffffe000200980:	03010113          	addi	sp,sp,48
ffffffe000200984:	00008067          	ret

ffffffe000200988 <do_timer>:

void do_timer(void) {
ffffffe000200988:	ff010113          	addi	sp,sp,-16
ffffffe00020098c:	00113423          	sd	ra,8(sp)
ffffffe000200990:	00813023          	sd	s0,0(sp)
ffffffe000200994:	01010413          	addi	s0,sp,16
    if(current->counter == 0) schedule();
ffffffe000200998:	00003797          	auipc	a5,0x3
ffffffe00020099c:	67878793          	addi	a5,a5,1656 # ffffffe000204010 <current>
ffffffe0002009a0:	0007b783          	ld	a5,0(a5)
ffffffe0002009a4:	0107b783          	ld	a5,16(a5)
ffffffe0002009a8:	00079663          	bnez	a5,ffffffe0002009b4 <do_timer+0x2c>
ffffffe0002009ac:	040000ef          	jal	ra,ffffffe0002009ec <schedule>
    else if(--current->counter == 0) schedule(); 
}
ffffffe0002009b0:	0280006f          	j	ffffffe0002009d8 <do_timer+0x50>
    else if(--current->counter == 0) schedule(); 
ffffffe0002009b4:	00003797          	auipc	a5,0x3
ffffffe0002009b8:	65c78793          	addi	a5,a5,1628 # ffffffe000204010 <current>
ffffffe0002009bc:	0007b783          	ld	a5,0(a5)
ffffffe0002009c0:	0107b703          	ld	a4,16(a5)
ffffffe0002009c4:	fff70713          	addi	a4,a4,-1 # fff <_skernel-0xffffffe0001ff001>
ffffffe0002009c8:	00e7b823          	sd	a4,16(a5)
ffffffe0002009cc:	0107b783          	ld	a5,16(a5)
ffffffe0002009d0:	00079463          	bnez	a5,ffffffe0002009d8 <do_timer+0x50>
ffffffe0002009d4:	018000ef          	jal	ra,ffffffe0002009ec <schedule>
}
ffffffe0002009d8:	00000013          	nop
ffffffe0002009dc:	00813083          	ld	ra,8(sp)
ffffffe0002009e0:	00013403          	ld	s0,0(sp)
ffffffe0002009e4:	01010113          	addi	sp,sp,16
ffffffe0002009e8:	00008067          	ret

ffffffe0002009ec <schedule>:

void schedule(void) {
ffffffe0002009ec:	fd010113          	addi	sp,sp,-48
ffffffe0002009f0:	02113423          	sd	ra,40(sp)
ffffffe0002009f4:	02813023          	sd	s0,32(sp)
ffffffe0002009f8:	03010413          	addi	s0,sp,48
    // int i,min_counter;
    struct task_struct* next;
    // printk("SHEDULE!\n");
	while (1) {
		int min_counter = PRIORITY_MAX+1;
ffffffe0002009fc:	00600793          	li	a5,6
ffffffe000200a00:	fef42223          	sw	a5,-28(s0)
		for(int i = 1;i < NR_TASKS;i ++){
ffffffe000200a04:	00100793          	li	a5,1
ffffffe000200a08:	fef42023          	sw	a5,-32(s0)
ffffffe000200a0c:	0b80006f          	j	ffffffe000200ac4 <schedule+0xd8>
            // printk("i = %d, task[%d]->counter = %d \n",i,task[i]->pid,task[i]->counter);
            if(task[i]->state == TASK_RUNNING  && task[i]->counter != 0 && (int)task[i]->counter < min_counter){
ffffffe000200a10:	00003717          	auipc	a4,0x3
ffffffe000200a14:	61870713          	addi	a4,a4,1560 # ffffffe000204028 <task>
ffffffe000200a18:	fe042783          	lw	a5,-32(s0)
ffffffe000200a1c:	00379793          	slli	a5,a5,0x3
ffffffe000200a20:	00f707b3          	add	a5,a4,a5
ffffffe000200a24:	0007b783          	ld	a5,0(a5)
ffffffe000200a28:	0087b783          	ld	a5,8(a5)
ffffffe000200a2c:	08079663          	bnez	a5,ffffffe000200ab8 <schedule+0xcc>
ffffffe000200a30:	00003717          	auipc	a4,0x3
ffffffe000200a34:	5f870713          	addi	a4,a4,1528 # ffffffe000204028 <task>
ffffffe000200a38:	fe042783          	lw	a5,-32(s0)
ffffffe000200a3c:	00379793          	slli	a5,a5,0x3
ffffffe000200a40:	00f707b3          	add	a5,a4,a5
ffffffe000200a44:	0007b783          	ld	a5,0(a5)
ffffffe000200a48:	0107b783          	ld	a5,16(a5)
ffffffe000200a4c:	06078663          	beqz	a5,ffffffe000200ab8 <schedule+0xcc>
ffffffe000200a50:	00003717          	auipc	a4,0x3
ffffffe000200a54:	5d870713          	addi	a4,a4,1496 # ffffffe000204028 <task>
ffffffe000200a58:	fe042783          	lw	a5,-32(s0)
ffffffe000200a5c:	00379793          	slli	a5,a5,0x3
ffffffe000200a60:	00f707b3          	add	a5,a4,a5
ffffffe000200a64:	0007b783          	ld	a5,0(a5)
ffffffe000200a68:	0107b783          	ld	a5,16(a5)
ffffffe000200a6c:	0007871b          	sext.w	a4,a5
ffffffe000200a70:	fe442783          	lw	a5,-28(s0)
ffffffe000200a74:	0007879b          	sext.w	a5,a5
ffffffe000200a78:	04f75063          	bge	a4,a5,ffffffe000200ab8 <schedule+0xcc>
                min_counter = task[i]->counter, next = task[i];
ffffffe000200a7c:	00003717          	auipc	a4,0x3
ffffffe000200a80:	5ac70713          	addi	a4,a4,1452 # ffffffe000204028 <task>
ffffffe000200a84:	fe042783          	lw	a5,-32(s0)
ffffffe000200a88:	00379793          	slli	a5,a5,0x3
ffffffe000200a8c:	00f707b3          	add	a5,a4,a5
ffffffe000200a90:	0007b783          	ld	a5,0(a5)
ffffffe000200a94:	0107b783          	ld	a5,16(a5)
ffffffe000200a98:	fef42223          	sw	a5,-28(s0)
ffffffe000200a9c:	00003717          	auipc	a4,0x3
ffffffe000200aa0:	58c70713          	addi	a4,a4,1420 # ffffffe000204028 <task>
ffffffe000200aa4:	fe042783          	lw	a5,-32(s0)
ffffffe000200aa8:	00379793          	slli	a5,a5,0x3
ffffffe000200aac:	00f707b3          	add	a5,a4,a5
ffffffe000200ab0:	0007b783          	ld	a5,0(a5)
ffffffe000200ab4:	fef43423          	sd	a5,-24(s0)
		for(int i = 1;i < NR_TASKS;i ++){
ffffffe000200ab8:	fe042783          	lw	a5,-32(s0)
ffffffe000200abc:	0017879b          	addiw	a5,a5,1
ffffffe000200ac0:	fef42023          	sw	a5,-32(s0)
ffffffe000200ac4:	fe042783          	lw	a5,-32(s0)
ffffffe000200ac8:	0007871b          	sext.w	a4,a5
ffffffe000200acc:	00300793          	li	a5,3
ffffffe000200ad0:	f4e7d0e3          	bge	a5,a4,ffffffe000200a10 <schedule+0x24>
                // printk("maxcounter = %d\n",max_counter);
            }
        }
		if (min_counter != PRIORITY_MAX+1){
ffffffe000200ad4:	fe442783          	lw	a5,-28(s0)
ffffffe000200ad8:	0007871b          	sext.w	a4,a5
ffffffe000200adc:	00600793          	li	a5,6
ffffffe000200ae0:	10f71663          	bne	a4,a5,ffffffe000200bec <schedule+0x200>
            // printk("out!\n");
            break;
        }
		for(int i = 1;i < NR_TASKS;i ++){
ffffffe000200ae4:	00100793          	li	a5,1
ffffffe000200ae8:	fcf42e23          	sw	a5,-36(s0)
ffffffe000200aec:	0ec0006f          	j	ffffffe000200bd8 <schedule+0x1ec>
            if (task[i]){
ffffffe000200af0:	00003717          	auipc	a4,0x3
ffffffe000200af4:	53870713          	addi	a4,a4,1336 # ffffffe000204028 <task>
ffffffe000200af8:	fdc42783          	lw	a5,-36(s0)
ffffffe000200afc:	00379793          	slli	a5,a5,0x3
ffffffe000200b00:	00f707b3          	add	a5,a4,a5
ffffffe000200b04:	0007b783          	ld	a5,0(a5)
ffffffe000200b08:	0c078263          	beqz	a5,ffffffe000200bcc <schedule+0x1e0>
                task[i]->counter = (task[i]->counter >> 1) + task[i]->priority;
ffffffe000200b0c:	00003717          	auipc	a4,0x3
ffffffe000200b10:	51c70713          	addi	a4,a4,1308 # ffffffe000204028 <task>
ffffffe000200b14:	fdc42783          	lw	a5,-36(s0)
ffffffe000200b18:	00379793          	slli	a5,a5,0x3
ffffffe000200b1c:	00f707b3          	add	a5,a4,a5
ffffffe000200b20:	0007b783          	ld	a5,0(a5)
ffffffe000200b24:	0107b783          	ld	a5,16(a5)
ffffffe000200b28:	0017d693          	srli	a3,a5,0x1
ffffffe000200b2c:	00003717          	auipc	a4,0x3
ffffffe000200b30:	4fc70713          	addi	a4,a4,1276 # ffffffe000204028 <task>
ffffffe000200b34:	fdc42783          	lw	a5,-36(s0)
ffffffe000200b38:	00379793          	slli	a5,a5,0x3
ffffffe000200b3c:	00f707b3          	add	a5,a4,a5
ffffffe000200b40:	0007b783          	ld	a5,0(a5)
ffffffe000200b44:	0187b703          	ld	a4,24(a5)
ffffffe000200b48:	00003617          	auipc	a2,0x3
ffffffe000200b4c:	4e060613          	addi	a2,a2,1248 # ffffffe000204028 <task>
ffffffe000200b50:	fdc42783          	lw	a5,-36(s0)
ffffffe000200b54:	00379793          	slli	a5,a5,0x3
ffffffe000200b58:	00f607b3          	add	a5,a2,a5
ffffffe000200b5c:	0007b783          	ld	a5,0(a5)
ffffffe000200b60:	00e68733          	add	a4,a3,a4
ffffffe000200b64:	00e7b823          	sd	a4,16(a5)
                printk("SET [PID = %d, PRIORITY = %d, COUNTER = %d]\n",task[i]->pid,task[i]->priority,task[i]->counter);
ffffffe000200b68:	00003717          	auipc	a4,0x3
ffffffe000200b6c:	4c070713          	addi	a4,a4,1216 # ffffffe000204028 <task>
ffffffe000200b70:	fdc42783          	lw	a5,-36(s0)
ffffffe000200b74:	00379793          	slli	a5,a5,0x3
ffffffe000200b78:	00f707b3          	add	a5,a4,a5
ffffffe000200b7c:	0007b783          	ld	a5,0(a5)
ffffffe000200b80:	0207b583          	ld	a1,32(a5)
ffffffe000200b84:	00003717          	auipc	a4,0x3
ffffffe000200b88:	4a470713          	addi	a4,a4,1188 # ffffffe000204028 <task>
ffffffe000200b8c:	fdc42783          	lw	a5,-36(s0)
ffffffe000200b90:	00379793          	slli	a5,a5,0x3
ffffffe000200b94:	00f707b3          	add	a5,a4,a5
ffffffe000200b98:	0007b783          	ld	a5,0(a5)
ffffffe000200b9c:	0187b603          	ld	a2,24(a5)
ffffffe000200ba0:	00003717          	auipc	a4,0x3
ffffffe000200ba4:	48870713          	addi	a4,a4,1160 # ffffffe000204028 <task>
ffffffe000200ba8:	fdc42783          	lw	a5,-36(s0)
ffffffe000200bac:	00379793          	slli	a5,a5,0x3
ffffffe000200bb0:	00f707b3          	add	a5,a4,a5
ffffffe000200bb4:	0007b783          	ld	a5,0(a5)
ffffffe000200bb8:	0107b783          	ld	a5,16(a5)
ffffffe000200bbc:	00078693          	mv	a3,a5
ffffffe000200bc0:	00001517          	auipc	a0,0x1
ffffffe000200bc4:	4b850513          	addi	a0,a0,1208 # ffffffe000202078 <_srodata+0x78>
ffffffe000200bc8:	369000ef          	jal	ra,ffffffe000201730 <printk>
		for(int i = 1;i < NR_TASKS;i ++){
ffffffe000200bcc:	fdc42783          	lw	a5,-36(s0)
ffffffe000200bd0:	0017879b          	addiw	a5,a5,1
ffffffe000200bd4:	fcf42e23          	sw	a5,-36(s0)
ffffffe000200bd8:	fdc42783          	lw	a5,-36(s0)
ffffffe000200bdc:	0007871b          	sext.w	a4,a5
ffffffe000200be0:	00300793          	li	a5,3
ffffffe000200be4:	f0e7d6e3          	bge	a5,a4,ffffffe000200af0 <schedule+0x104>
	while (1) {
ffffffe000200be8:	e15ff06f          	j	ffffffe0002009fc <schedule+0x10>
            break;
ffffffe000200bec:	00000013          	nop
            }
        }
	}
	switch_to(next);
ffffffe000200bf0:	fe843503          	ld	a0,-24(s0)
ffffffe000200bf4:	d01ff0ef          	jal	ra,ffffffe0002008f4 <switch_to>
}
ffffffe000200bf8:	00000013          	nop
ffffffe000200bfc:	02813083          	ld	ra,40(sp)
ffffffe000200c00:	02013403          	ld	s0,32(sp)
ffffffe000200c04:	03010113          	addi	sp,sp,48
ffffffe000200c08:	00008067          	ret

ffffffe000200c0c <sbi_ecall>:
#include "types.h"
#include "sbi.h"

struct sbiret sbi_ecall(int ext, int fid, 
                        uint64 arg0,uint64 arg1, uint64 arg2,
                        uint64 arg3, uint64 arg4,uint64 arg5){
ffffffe000200c0c:	f9010113          	addi	sp,sp,-112
ffffffe000200c10:	06813423          	sd	s0,104(sp)
ffffffe000200c14:	07010413          	addi	s0,sp,112
ffffffe000200c18:	fcc43023          	sd	a2,-64(s0)
ffffffe000200c1c:	fad43c23          	sd	a3,-72(s0)
ffffffe000200c20:	fae43823          	sd	a4,-80(s0)
ffffffe000200c24:	faf43423          	sd	a5,-88(s0)
ffffffe000200c28:	fb043023          	sd	a6,-96(s0)
ffffffe000200c2c:	f9143c23          	sd	a7,-104(s0)
ffffffe000200c30:	00050793          	mv	a5,a0
ffffffe000200c34:	fcf42623          	sw	a5,-52(s0)
ffffffe000200c38:	00058793          	mv	a5,a1
ffffffe000200c3c:	fcf42423          	sw	a5,-56(s0)
    struct sbiret ret;
    register uint64 a0 asm("a0") = (uint64)(arg0);
ffffffe000200c40:	fc043503          	ld	a0,-64(s0)
    register uint64 a1 asm("a1") = (uint64)(arg1);
ffffffe000200c44:	fb843583          	ld	a1,-72(s0)
    register uint64 a2 asm("a2") = (uint64)(arg2);
ffffffe000200c48:	fb043603          	ld	a2,-80(s0)
    register uint64 a3 asm("a3") = (uint64)(arg3);
ffffffe000200c4c:	fa843683          	ld	a3,-88(s0)
    register uint64 a4 asm("a4") = (uint64)(arg4);
ffffffe000200c50:	fa043703          	ld	a4,-96(s0)
    register uint64 a5 asm("a5") = (uint64)(arg5);
ffffffe000200c54:	f9843783          	ld	a5,-104(s0)
    register uint64 a6 asm("a6") = (uint64)(fid);
ffffffe000200c58:	fc842803          	lw	a6,-56(s0)
    register uint64 a7 asm("a7") = (uint64)(ext);
ffffffe000200c5c:	fcc42883          	lw	a7,-52(s0)
    asm volatile (
ffffffe000200c60:	00000073          	ecall
    "ecall"
    : "+r" (a0), "+r" (a1)
    : "r" (a2), "r" (a3), "r" (a4), "r" (a5), "r" (a6), "r" (a7)
    : "memory"
    );
    ret.error = a0;
ffffffe000200c64:	00050793          	mv	a5,a0
ffffffe000200c68:	fcf43823          	sd	a5,-48(s0)
    ret.value = a1;
ffffffe000200c6c:	00058793          	mv	a5,a1
ffffffe000200c70:	fcf43c23          	sd	a5,-40(s0)
    return ret;
ffffffe000200c74:	fd043783          	ld	a5,-48(s0)
ffffffe000200c78:	fef43023          	sd	a5,-32(s0)
ffffffe000200c7c:	fd843783          	ld	a5,-40(s0)
ffffffe000200c80:	fef43423          	sd	a5,-24(s0)
ffffffe000200c84:	fe043703          	ld	a4,-32(s0)
ffffffe000200c88:	fe843783          	ld	a5,-24(s0)
ffffffe000200c8c:	00070313          	mv	t1,a4
ffffffe000200c90:	00078393          	mv	t2,a5
ffffffe000200c94:	00030713          	mv	a4,t1
ffffffe000200c98:	00038793          	mv	a5,t2
}
ffffffe000200c9c:	00070513          	mv	a0,a4
ffffffe000200ca0:	00078593          	mv	a1,a5
ffffffe000200ca4:	06813403          	ld	s0,104(sp)
ffffffe000200ca8:	07010113          	addi	sp,sp,112
ffffffe000200cac:	00008067          	ret

ffffffe000200cb0 <sbi_set_timer>:

void sbi_set_timer(uint64 stime_v){
ffffffe000200cb0:	fe010113          	addi	sp,sp,-32
ffffffe000200cb4:	00113c23          	sd	ra,24(sp)
ffffffe000200cb8:	00813823          	sd	s0,16(sp)
ffffffe000200cbc:	02010413          	addi	s0,sp,32
ffffffe000200cc0:	fea43423          	sd	a0,-24(s0)
    sbi_ecall(0x00,0,stime_v,0,0,0,0,0);
ffffffe000200cc4:	00000893          	li	a7,0
ffffffe000200cc8:	00000813          	li	a6,0
ffffffe000200ccc:	00000793          	li	a5,0
ffffffe000200cd0:	00000713          	li	a4,0
ffffffe000200cd4:	00000693          	li	a3,0
ffffffe000200cd8:	fe843603          	ld	a2,-24(s0)
ffffffe000200cdc:	00000593          	li	a1,0
ffffffe000200ce0:	00000513          	li	a0,0
ffffffe000200ce4:	f29ff0ef          	jal	ra,ffffffe000200c0c <sbi_ecall>
}
ffffffe000200ce8:	00000013          	nop
ffffffe000200cec:	01813083          	ld	ra,24(sp)
ffffffe000200cf0:	01013403          	ld	s0,16(sp)
ffffffe000200cf4:	02010113          	addi	sp,sp,32
ffffffe000200cf8:	00008067          	ret

ffffffe000200cfc <trap_handler>:
#include "sbi.h"
#include "clock.h"
// unsigned long TIMECLOCK = 0x30000;
static int cnt = 0;

void trap_handler(unsigned long scause, unsigned long sepc) {
ffffffe000200cfc:	fe010113          	addi	sp,sp,-32
ffffffe000200d00:	00113c23          	sd	ra,24(sp)
ffffffe000200d04:	00813823          	sd	s0,16(sp)
ffffffe000200d08:	02010413          	addi	s0,sp,32
ffffffe000200d0c:	fea43423          	sd	a0,-24(s0)
ffffffe000200d10:	feb43023          	sd	a1,-32(s0)
    switch(scause >> 63){ //Highest bit
ffffffe000200d14:	fe843783          	ld	a5,-24(s0)
ffffffe000200d18:	03f7d793          	srli	a5,a5,0x3f
ffffffe000200d1c:	02078c63          	beqz	a5,ffffffe000200d54 <trap_handler+0x58>
ffffffe000200d20:	00100713          	li	a4,1
ffffffe000200d24:	06e79263          	bne	a5,a4,ffffffe000200d88 <trap_handler+0x8c>
        case 1: //Interrupt
            switch (scause & 0x7FFFFFFFFFFFFFFF){
ffffffe000200d28:	fe843703          	ld	a4,-24(s0)
ffffffe000200d2c:	fff00793          	li	a5,-1
ffffffe000200d30:	0017d793          	srli	a5,a5,0x1
ffffffe000200d34:	00f77733          	and	a4,a4,a5
ffffffe000200d38:	00500793          	li	a5,5
ffffffe000200d3c:	00f71863          	bne	a4,a5,ffffffe000200d4c <trap_handler+0x50>
                case 5: //Supervisor Mode Timer Interrupt
                    clock_set_next_event();
ffffffe000200d40:	d14ff0ef          	jal	ra,ffffffe000200254 <clock_set_next_event>
                    do_timer();
ffffffe000200d44:	c45ff0ef          	jal	ra,ffffffe000200988 <do_timer>
                    break;
ffffffe000200d48:	0080006f          	j	ffffffe000200d50 <trap_handler+0x54>
                default:
                    break;
ffffffe000200d4c:	00000013          	nop
            }
            break;
ffffffe000200d50:	0340006f          	j	ffffffe000200d84 <trap_handler+0x88>
        case 0: //Exception
            if(!cnt)printk("I LOVE SYS!\n");
ffffffe000200d54:	00003797          	auipc	a5,0x3
ffffffe000200d58:	2c478793          	addi	a5,a5,708 # ffffffe000204018 <cnt>
ffffffe000200d5c:	0007a783          	lw	a5,0(a5)
ffffffe000200d60:	00079863          	bnez	a5,ffffffe000200d70 <trap_handler+0x74>
ffffffe000200d64:	00001517          	auipc	a0,0x1
ffffffe000200d68:	34450513          	addi	a0,a0,836 # ffffffe0002020a8 <_srodata+0xa8>
ffffffe000200d6c:	1c5000ef          	jal	ra,ffffffe000201730 <printk>
            cnt = 1;
ffffffe000200d70:	00003797          	auipc	a5,0x3
ffffffe000200d74:	2a878793          	addi	a5,a5,680 # ffffffe000204018 <cnt>
ffffffe000200d78:	00100713          	li	a4,1
ffffffe000200d7c:	00e7a023          	sw	a4,0(a5)
            break;
ffffffe000200d80:	00000013          	nop
    }
    return;
ffffffe000200d84:	00000013          	nop
ffffffe000200d88:	00000013          	nop
ffffffe000200d8c:	01813083          	ld	ra,24(sp)
ffffffe000200d90:	01013403          	ld	s0,16(sp)
ffffffe000200d94:	02010113          	addi	sp,sp,32
ffffffe000200d98:	00008067          	ret

ffffffe000200d9c <setup_vm>:
unsigned long early_pgtbl[512] __attribute__((__aligned__(0x1000)));
/* swapper_pg_dir: kernel pagetable 根目录， 在 setup_vm_final 进行映射。 */
unsigned long swapper_pg_dir[512] __attribute__((__aligned__(0x1000)));

void setup_vm(void)
{
ffffffe000200d9c:	fe010113          	addi	sp,sp,-32
ffffffe000200da0:	00113c23          	sd	ra,24(sp)
ffffffe000200da4:	00813823          	sd	s0,16(sp)
ffffffe000200da8:	02010413          	addi	s0,sp,32
        中间9 bit 作为 early_pgtbl 的 index
        低 30 bit 作为 页内偏移 这里注意到 30 = 9 + 9 + 12， 即我们只使用根页表， 根页表的每个 entry 都对应 1GB 的区域。
    3. Page Table Entry 的权限 V | R | W | X 位设置为 1
    */
    uint64 index,ppn2;
    ppn2 = (uint64)(PHY_START & 0xffffffc0000000) >> 2;
ffffffe000200dac:	200007b7          	lui	a5,0x20000
ffffffe000200db0:	fef43423          	sd	a5,-24(s0)
    // 等值映射
    index = ((uint64)PHY_START >> 30) & 511;
ffffffe000200db4:	00200793          	li	a5,2
ffffffe000200db8:	fef43023          	sd	a5,-32(s0)
    early_pgtbl[index] = ppn2 | PTE_V | PTE_R | PTE_W | PTE_X | PTE_A | PTE_D;
ffffffe000200dbc:	fe843783          	ld	a5,-24(s0)
ffffffe000200dc0:	0cf7e713          	ori	a4,a5,207
ffffffe000200dc4:	00004697          	auipc	a3,0x4
ffffffe000200dc8:	23c68693          	addi	a3,a3,572 # ffffffe000205000 <early_pgtbl>
ffffffe000200dcc:	fe043783          	ld	a5,-32(s0)
ffffffe000200dd0:	00379793          	slli	a5,a5,0x3
ffffffe000200dd4:	00f687b3          	add	a5,a3,a5
ffffffe000200dd8:	00e7b023          	sd	a4,0(a5) # 20000000 <_skernel-0xffffffdfe0200000>
    // 映射至高地址
    index = (VM_START >> 30) & 511;
ffffffe000200ddc:	18000793          	li	a5,384
ffffffe000200de0:	fef43023          	sd	a5,-32(s0)
    early_pgtbl[index] = ppn2 | PTE_V | PTE_R | PTE_W | PTE_X | PTE_A | PTE_D; 
ffffffe000200de4:	fe843783          	ld	a5,-24(s0)
ffffffe000200de8:	0cf7e713          	ori	a4,a5,207
ffffffe000200dec:	00004697          	auipc	a3,0x4
ffffffe000200df0:	21468693          	addi	a3,a3,532 # ffffffe000205000 <early_pgtbl>
ffffffe000200df4:	fe043783          	ld	a5,-32(s0)
ffffffe000200df8:	00379793          	slli	a5,a5,0x3
ffffffe000200dfc:	00f687b3          	add	a5,a3,a5
ffffffe000200e00:	00e7b023          	sd	a4,0(a5)
    
    printk("SETUP_VM is OK\n");
ffffffe000200e04:	00001517          	auipc	a0,0x1
ffffffe000200e08:	2b450513          	addi	a0,a0,692 # ffffffe0002020b8 <_srodata+0xb8>
ffffffe000200e0c:	125000ef          	jal	ra,ffffffe000201730 <printk>
}
ffffffe000200e10:	00000013          	nop
ffffffe000200e14:	01813083          	ld	ra,24(sp)
ffffffe000200e18:	01013403          	ld	s0,16(sp)
ffffffe000200e1c:	02010113          	addi	sp,sp,32
ffffffe000200e20:	00008067          	ret

ffffffe000200e24 <setup_vm_final>:


void setup_vm_final(void) {
ffffffe000200e24:	fb010113          	addi	sp,sp,-80
ffffffe000200e28:	04113423          	sd	ra,72(sp)
ffffffe000200e2c:	04813023          	sd	s0,64(sp)
ffffffe000200e30:	05010413          	addi	s0,sp,80

    memset(swapper_pg_dir, 0x0, PGSIZE);
ffffffe000200e34:	00001637          	lui	a2,0x1
ffffffe000200e38:	00000593          	li	a1,0
ffffffe000200e3c:	00005517          	auipc	a0,0x5
ffffffe000200e40:	1c450513          	addi	a0,a0,452 # ffffffe000206000 <swapper_pg_dir>
ffffffe000200e44:	46d000ef          	jal	ra,ffffffe000201ab0 <memset>
    uint64 va,pa,text_size,rodata_size,other_size;
    text_size = _srodata - _stext;
ffffffe000200e48:	00001717          	auipc	a4,0x1
ffffffe000200e4c:	1b870713          	addi	a4,a4,440 # ffffffe000202000 <_srodata>
ffffffe000200e50:	fffff797          	auipc	a5,0xfffff
ffffffe000200e54:	1b078793          	addi	a5,a5,432 # ffffffe000200000 <_skernel>
ffffffe000200e58:	40f707b3          	sub	a5,a4,a5
ffffffe000200e5c:	fef43423          	sd	a5,-24(s0)
    rodata_size = _sdata - _srodata;
ffffffe000200e60:	00002717          	auipc	a4,0x2
ffffffe000200e64:	1a070713          	addi	a4,a4,416 # ffffffe000203000 <TIMECLOCK>
ffffffe000200e68:	00001797          	auipc	a5,0x1
ffffffe000200e6c:	19878793          	addi	a5,a5,408 # ffffffe000202000 <_srodata>
ffffffe000200e70:	40f707b3          	sub	a5,a4,a5
ffffffe000200e74:	fef43023          	sd	a5,-32(s0)
    other_size = PHY_SIZE - (_sdata-_stext);
ffffffe000200e78:	00002717          	auipc	a4,0x2
ffffffe000200e7c:	18870713          	addi	a4,a4,392 # ffffffe000203000 <TIMECLOCK>
ffffffe000200e80:	fffff797          	auipc	a5,0xfffff
ffffffe000200e84:	18078793          	addi	a5,a5,384 # ffffffe000200000 <_skernel>
ffffffe000200e88:	40f707b3          	sub	a5,a4,a5
ffffffe000200e8c:	00210737          	lui	a4,0x210
ffffffe000200e90:	40f707b3          	sub	a5,a4,a5
ffffffe000200e94:	fcf43c23          	sd	a5,-40(s0)

    // No OpenSBI mapping required

    // mapping kernel text X|-|R|V
    va = VM_START + OPENSBI_SIZE;
ffffffe000200e98:	f00017b7          	lui	a5,0xf0001
ffffffe000200e9c:	00979793          	slli	a5,a5,0x9
ffffffe000200ea0:	fcf43823          	sd	a5,-48(s0)
    pa = PHY_START + OPENSBI_SIZE;
ffffffe000200ea4:	40100793          	li	a5,1025
ffffffe000200ea8:	01579793          	slli	a5,a5,0x15
ffffffe000200eac:	fcf43423          	sd	a5,-56(s0)
    create_mapping(swapper_pg_dir, va, pa, text_size, PTE_X | PTE_R | PTE_V | PTE_A | PTE_D);
ffffffe000200eb0:	0cb00713          	li	a4,203
ffffffe000200eb4:	fe843683          	ld	a3,-24(s0)
ffffffe000200eb8:	fc843603          	ld	a2,-56(s0)
ffffffe000200ebc:	fd043583          	ld	a1,-48(s0)
ffffffe000200ec0:	00005517          	auipc	a0,0x5
ffffffe000200ec4:	14050513          	addi	a0,a0,320 # ffffffe000206000 <swapper_pg_dir>
ffffffe000200ec8:	0d0000ef          	jal	ra,ffffffe000200f98 <create_mapping>

    // mapping kernel rodata -|-|R|V
    va += text_size;
ffffffe000200ecc:	fd043703          	ld	a4,-48(s0)
ffffffe000200ed0:	fe843783          	ld	a5,-24(s0)
ffffffe000200ed4:	00f707b3          	add	a5,a4,a5
ffffffe000200ed8:	fcf43823          	sd	a5,-48(s0)
    pa += text_size;
ffffffe000200edc:	fc843703          	ld	a4,-56(s0)
ffffffe000200ee0:	fe843783          	ld	a5,-24(s0)
ffffffe000200ee4:	00f707b3          	add	a5,a4,a5
ffffffe000200ee8:	fcf43423          	sd	a5,-56(s0)
    create_mapping(swapper_pg_dir, va, pa, rodata_size, PTE_R | PTE_V | PTE_A | PTE_D);
ffffffe000200eec:	0c300713          	li	a4,195
ffffffe000200ef0:	fe043683          	ld	a3,-32(s0)
ffffffe000200ef4:	fc843603          	ld	a2,-56(s0)
ffffffe000200ef8:	fd043583          	ld	a1,-48(s0)
ffffffe000200efc:	00005517          	auipc	a0,0x5
ffffffe000200f00:	10450513          	addi	a0,a0,260 # ffffffe000206000 <swapper_pg_dir>
ffffffe000200f04:	094000ef          	jal	ra,ffffffe000200f98 <create_mapping>
  
    // mapping other memory -|W|R|V
    va += rodata_size;
ffffffe000200f08:	fd043703          	ld	a4,-48(s0)
ffffffe000200f0c:	fe043783          	ld	a5,-32(s0)
ffffffe000200f10:	00f707b3          	add	a5,a4,a5
ffffffe000200f14:	fcf43823          	sd	a5,-48(s0)
    pa += rodata_size;
ffffffe000200f18:	fc843703          	ld	a4,-56(s0)
ffffffe000200f1c:	fe043783          	ld	a5,-32(s0)
ffffffe000200f20:	00f707b3          	add	a5,a4,a5
ffffffe000200f24:	fcf43423          	sd	a5,-56(s0)
    create_mapping(swapper_pg_dir, va, pa, other_size, PTE_W | PTE_R | PTE_V | PTE_A | PTE_D);
ffffffe000200f28:	0c700713          	li	a4,199
ffffffe000200f2c:	fd843683          	ld	a3,-40(s0)
ffffffe000200f30:	fc843603          	ld	a2,-56(s0)
ffffffe000200f34:	fd043583          	ld	a1,-48(s0)
ffffffe000200f38:	00005517          	auipc	a0,0x5
ffffffe000200f3c:	0c850513          	addi	a0,a0,200 # ffffffe000206000 <swapper_pg_dir>
ffffffe000200f40:	058000ef          	jal	ra,ffffffe000200f98 <create_mapping>

    // write satp register  
    uint64 satpVal = (((uint64)(swapper_pg_dir) - PA2VA_OFFSET) >> 12) | ((uint64)(8) << 60);
ffffffe000200f44:	00005717          	auipc	a4,0x5
ffffffe000200f48:	0bc70713          	addi	a4,a4,188 # ffffffe000206000 <swapper_pg_dir>
ffffffe000200f4c:	04100793          	li	a5,65
ffffffe000200f50:	01f79793          	slli	a5,a5,0x1f
ffffffe000200f54:	00f707b3          	add	a5,a4,a5
ffffffe000200f58:	00c7d713          	srli	a4,a5,0xc
ffffffe000200f5c:	fff00793          	li	a5,-1
ffffffe000200f60:	03f79793          	slli	a5,a5,0x3f
ffffffe000200f64:	00f767b3          	or	a5,a4,a5
ffffffe000200f68:	fcf43023          	sd	a5,-64(s0)
    csr_write(satp, satpVal); 
ffffffe000200f6c:	fc043783          	ld	a5,-64(s0)
ffffffe000200f70:	faf43c23          	sd	a5,-72(s0)
ffffffe000200f74:	fb843783          	ld	a5,-72(s0)
ffffffe000200f78:	18079073          	csrw	satp,a5

    // flush TLB
    asm volatile("sfence.vma zero, zero");
ffffffe000200f7c:	12000073          	sfence.vma

    // flush icache
    asm volatile("fence.i");
ffffffe000200f80:	0000100f          	fence.i
    return;
ffffffe000200f84:	00000013          	nop
}
ffffffe000200f88:	04813083          	ld	ra,72(sp)
ffffffe000200f8c:	04013403          	ld	s0,64(sp)
ffffffe000200f90:	05010113          	addi	sp,sp,80
ffffffe000200f94:	00008067          	ret

ffffffe000200f98 <create_mapping>:


/* 创建多级页表映射关系 */
void create_mapping(uint64 *pgtbl, uint64 va, uint64 pa, uint64 sz, uint64 perm) {
ffffffe000200f98:	f8010113          	addi	sp,sp,-128
ffffffe000200f9c:	06113c23          	sd	ra,120(sp)
ffffffe000200fa0:	06813823          	sd	s0,112(sp)
ffffffe000200fa4:	08010413          	addi	s0,sp,128
ffffffe000200fa8:	faa43423          	sd	a0,-88(s0)
ffffffe000200fac:	fab43023          	sd	a1,-96(s0)
ffffffe000200fb0:	f8c43c23          	sd	a2,-104(s0)
ffffffe000200fb4:	f8d43823          	sd	a3,-112(s0)
ffffffe000200fb8:	f8e43423          	sd	a4,-120(s0)
    将给定的一段虚拟内存映射到物理内存上
    物理内存需要分页
    创建多级页表的时候可以使用 kalloc() 来获取一页作为页表目录
    可以使用 V bit 来判断页表项是否存在
    */
    uint64 page_num = 0, *table, pte, index, ppn;
ffffffe000200fbc:	fc043c23          	sd	zero,-40(s0)
    for( uint64 page_num = 0;page_num < sz;page_num += PGSIZE){
ffffffe000200fc0:	fe043023          	sd	zero,-32(s0)
ffffffe000200fc4:	1e00006f          	j	ffffffe0002011a4 <create_mapping+0x20c>
        table = pgtbl;      // 这是个虚拟地址
ffffffe000200fc8:	fa843783          	ld	a5,-88(s0)
ffffffe000200fcc:	fcf43823          	sd	a5,-48(s0)
        index = (va >> 30) & 0x1ff; // VPN2
ffffffe000200fd0:	fa043783          	ld	a5,-96(s0)
ffffffe000200fd4:	01e7d793          	srli	a5,a5,0x1e
ffffffe000200fd8:	1ff7f793          	andi	a5,a5,511
ffffffe000200fdc:	fcf43423          	sd	a5,-56(s0)
        pte = table[index];
ffffffe000200fe0:	fc843783          	ld	a5,-56(s0)
ffffffe000200fe4:	00379793          	slli	a5,a5,0x3
ffffffe000200fe8:	fd043703          	ld	a4,-48(s0)
ffffffe000200fec:	00f707b3          	add	a5,a4,a5
ffffffe000200ff0:	0007b783          	ld	a5,0(a5) # fffffffff0001000 <_estack+0x1fefdf7000>
ffffffe000200ff4:	fef43423          	sd	a5,-24(s0)
        if(!(pte & PTE_V)){     // 如果当前表项的 V 位是0
ffffffe000200ff8:	fe843783          	ld	a5,-24(s0)
ffffffe000200ffc:	0017f793          	andi	a5,a5,1
ffffffe000201000:	06079263          	bnez	a5,ffffffe000201064 <create_mapping+0xcc>
                                // 我们需要新建一个页表
            // 在物理空间上新建一个页
            uint64 newpageAddr = kalloc() - PA2VA_OFFSET; // kalloc会返回一个虚拟地址
ffffffe000201004:	c6cff0ef          	jal	ra,ffffffe000200470 <kalloc>
ffffffe000201008:	00050713          	mv	a4,a0
ffffffe00020100c:	04100793          	li	a5,65
ffffffe000201010:	01f79793          	slli	a5,a5,0x1f
ffffffe000201014:	00f707b3          	add	a5,a4,a5
ffffffe000201018:	fcf43023          	sd	a5,-64(s0)
                                                            // newtable指向一个物理空间上的物理地址
            memset((void *)newpageAddr,0, PGSIZE);
ffffffe00020101c:	fc043783          	ld	a5,-64(s0)
ffffffe000201020:	00001637          	lui	a2,0x1
ffffffe000201024:	00000593          	li	a1,0
ffffffe000201028:	00078513          	mv	a0,a5
ffffffe00020102c:	285000ef          	jal	ra,ffffffe000201ab0 <memset>
            // 根据物理地址的PPN填入pte的表项
            ppn = (newpageAddr >> 12) << 10;
ffffffe000201030:	fc043783          	ld	a5,-64(s0)
ffffffe000201034:	00c7d793          	srli	a5,a5,0xc
ffffffe000201038:	00a79793          	slli	a5,a5,0xa
ffffffe00020103c:	faf43c23          	sd	a5,-72(s0)
            pte = ppn | PTE_V;
ffffffe000201040:	fb843783          	ld	a5,-72(s0)
ffffffe000201044:	0017e793          	ori	a5,a5,1
ffffffe000201048:	fef43423          	sd	a5,-24(s0)
            table[index] = pte;
ffffffe00020104c:	fc843783          	ld	a5,-56(s0)
ffffffe000201050:	00379793          	slli	a5,a5,0x3
ffffffe000201054:	fd043703          	ld	a4,-48(s0)
ffffffe000201058:	00f707b3          	add	a5,a4,a5
ffffffe00020105c:	fe843703          	ld	a4,-24(s0)
ffffffe000201060:	00e7b023          	sd	a4,0(a5)
        }

        table = (uint64 *)(((pte >> 10) << 12) + PA2VA_OFFSET);   // 得到虚拟地址
ffffffe000201064:	fe843783          	ld	a5,-24(s0)
ffffffe000201068:	00a7d793          	srli	a5,a5,0xa
ffffffe00020106c:	00c79713          	slli	a4,a5,0xc
ffffffe000201070:	fbf00793          	li	a5,-65
ffffffe000201074:	01f79793          	slli	a5,a5,0x1f
ffffffe000201078:	00f707b3          	add	a5,a4,a5
ffffffe00020107c:	fcf43823          	sd	a5,-48(s0)
        index = (va >> 21) & 0x1ff; //VPN1
ffffffe000201080:	fa043783          	ld	a5,-96(s0)
ffffffe000201084:	0157d793          	srli	a5,a5,0x15
ffffffe000201088:	1ff7f793          	andi	a5,a5,511
ffffffe00020108c:	fcf43423          	sd	a5,-56(s0)
        pte = table[index];
ffffffe000201090:	fc843783          	ld	a5,-56(s0)
ffffffe000201094:	00379793          	slli	a5,a5,0x3
ffffffe000201098:	fd043703          	ld	a4,-48(s0)
ffffffe00020109c:	00f707b3          	add	a5,a4,a5
ffffffe0002010a0:	0007b783          	ld	a5,0(a5)
ffffffe0002010a4:	fef43423          	sd	a5,-24(s0)
        if(!(pte & PTE_V)){     // 如果当前表项的 V 位是0
ffffffe0002010a8:	fe843783          	ld	a5,-24(s0)
ffffffe0002010ac:	0017f793          	andi	a5,a5,1
ffffffe0002010b0:	06079263          	bnez	a5,ffffffe000201114 <create_mapping+0x17c>
                                // 我们需要新建一个页表
            // 在物理空间上新建一个页
            uint64 newpageAddr = kalloc() - PA2VA_OFFSET; // kalloc会返回一个虚拟地址
ffffffe0002010b4:	bbcff0ef          	jal	ra,ffffffe000200470 <kalloc>
ffffffe0002010b8:	00050713          	mv	a4,a0
ffffffe0002010bc:	04100793          	li	a5,65
ffffffe0002010c0:	01f79793          	slli	a5,a5,0x1f
ffffffe0002010c4:	00f707b3          	add	a5,a4,a5
ffffffe0002010c8:	faf43823          	sd	a5,-80(s0)
                                                            // newtable指向一个物理空间上的物理地址
            memset((void *)newpageAddr,0, PGSIZE);
ffffffe0002010cc:	fb043783          	ld	a5,-80(s0)
ffffffe0002010d0:	00001637          	lui	a2,0x1
ffffffe0002010d4:	00000593          	li	a1,0
ffffffe0002010d8:	00078513          	mv	a0,a5
ffffffe0002010dc:	1d5000ef          	jal	ra,ffffffe000201ab0 <memset>
            // 根据物理地址的PPN填入pte的表项
            ppn = (newpageAddr >> 12) << 10;
ffffffe0002010e0:	fb043783          	ld	a5,-80(s0)
ffffffe0002010e4:	00c7d793          	srli	a5,a5,0xc
ffffffe0002010e8:	00a79793          	slli	a5,a5,0xa
ffffffe0002010ec:	faf43c23          	sd	a5,-72(s0)
            pte = ppn | PTE_V;
ffffffe0002010f0:	fb843783          	ld	a5,-72(s0)
ffffffe0002010f4:	0017e793          	ori	a5,a5,1
ffffffe0002010f8:	fef43423          	sd	a5,-24(s0)
            table[index] = pte;
ffffffe0002010fc:	fc843783          	ld	a5,-56(s0)
ffffffe000201100:	00379793          	slli	a5,a5,0x3
ffffffe000201104:	fd043703          	ld	a4,-48(s0)
ffffffe000201108:	00f707b3          	add	a5,a4,a5
ffffffe00020110c:	fe843703          	ld	a4,-24(s0)
ffffffe000201110:	00e7b023          	sd	a4,0(a5)
        }

        table = (uint64 *)(((pte >> 10) << 12) + PA2VA_OFFSET);
ffffffe000201114:	fe843783          	ld	a5,-24(s0)
ffffffe000201118:	00a7d793          	srli	a5,a5,0xa
ffffffe00020111c:	00c79713          	slli	a4,a5,0xc
ffffffe000201120:	fbf00793          	li	a5,-65
ffffffe000201124:	01f79793          	slli	a5,a5,0x1f
ffffffe000201128:	00f707b3          	add	a5,a4,a5
ffffffe00020112c:	fcf43823          	sd	a5,-48(s0)
        index = (va >> 12) & 0x1ff; // VPN0
ffffffe000201130:	fa043783          	ld	a5,-96(s0)
ffffffe000201134:	00c7d793          	srli	a5,a5,0xc
ffffffe000201138:	1ff7f793          	andi	a5,a5,511
ffffffe00020113c:	fcf43423          	sd	a5,-56(s0)

        pte = (pa >> 12) << 10 | PTE_V | perm;
ffffffe000201140:	f9843783          	ld	a5,-104(s0)
ffffffe000201144:	00c7d793          	srli	a5,a5,0xc
ffffffe000201148:	00a79713          	slli	a4,a5,0xa
ffffffe00020114c:	f8843783          	ld	a5,-120(s0)
ffffffe000201150:	00f767b3          	or	a5,a4,a5
ffffffe000201154:	0017e793          	ori	a5,a5,1
ffffffe000201158:	fef43423          	sd	a5,-24(s0)
        table[index] = pte;
ffffffe00020115c:	fc843783          	ld	a5,-56(s0)
ffffffe000201160:	00379793          	slli	a5,a5,0x3
ffffffe000201164:	fd043703          	ld	a4,-48(s0)
ffffffe000201168:	00f707b3          	add	a5,a4,a5
ffffffe00020116c:	fe843703          	ld	a4,-24(s0)
ffffffe000201170:	00e7b023          	sd	a4,0(a5)

        va += PGSIZE;
ffffffe000201174:	fa043703          	ld	a4,-96(s0)
ffffffe000201178:	000017b7          	lui	a5,0x1
ffffffe00020117c:	00f707b3          	add	a5,a4,a5
ffffffe000201180:	faf43023          	sd	a5,-96(s0)
        pa += PGSIZE;
ffffffe000201184:	f9843703          	ld	a4,-104(s0)
ffffffe000201188:	000017b7          	lui	a5,0x1
ffffffe00020118c:	00f707b3          	add	a5,a4,a5
ffffffe000201190:	f8f43c23          	sd	a5,-104(s0)
    for( uint64 page_num = 0;page_num < sz;page_num += PGSIZE){
ffffffe000201194:	fe043703          	ld	a4,-32(s0)
ffffffe000201198:	000017b7          	lui	a5,0x1
ffffffe00020119c:	00f707b3          	add	a5,a4,a5
ffffffe0002011a0:	fef43023          	sd	a5,-32(s0)
ffffffe0002011a4:	fe043703          	ld	a4,-32(s0)
ffffffe0002011a8:	f9043783          	ld	a5,-112(s0)
ffffffe0002011ac:	e0f76ee3          	bltu	a4,a5,ffffffe000200fc8 <create_mapping+0x30>
    }


}
ffffffe0002011b0:	00000013          	nop
ffffffe0002011b4:	00000013          	nop
ffffffe0002011b8:	07813083          	ld	ra,120(sp)
ffffffe0002011bc:	07013403          	ld	s0,112(sp)
ffffffe0002011c0:	08010113          	addi	sp,sp,128
ffffffe0002011c4:	00008067          	ret

ffffffe0002011c8 <start_kernel>:
extern void test();
extern char _stext[];
extern char _srodata[];

int start_kernel()
{
ffffffe0002011c8:	ff010113          	addi	sp,sp,-16
ffffffe0002011cc:	00113423          	sd	ra,8(sp)
ffffffe0002011d0:	00813023          	sd	s0,0(sp)
ffffffe0002011d4:	01010413          	addi	s0,sp,16
    // printk("[BEFORE EDIT] _stext = %x\n", *_stext);       // 读
    // printk("[BEFORE EDIT] _srodata = %x\n", *_srodata);
    // *_stext = 0;                                          // 写
    // *_srodata = 0;

    test(); // DO NOT DELETE !!!
ffffffe0002011d8:	01c000ef          	jal	ra,ffffffe0002011f4 <test>

    return 0;
ffffffe0002011dc:	00000793          	li	a5,0
ffffffe0002011e0:	00078513          	mv	a0,a5
ffffffe0002011e4:	00813083          	ld	ra,8(sp)
ffffffe0002011e8:	00013403          	ld	s0,0(sp)
ffffffe0002011ec:	01010113          	addi	sp,sp,16
ffffffe0002011f0:	00008067          	ret

ffffffe0002011f4 <test>:
#include "defs.h"

// Please do not modify

void test()
{
ffffffe0002011f4:	ff010113          	addi	sp,sp,-16
ffffffe0002011f8:	00813423          	sd	s0,8(sp)
ffffffe0002011fc:	01010413          	addi	s0,sp,16
    while (1){}
ffffffe000201200:	0000006f          	j	ffffffe000201200 <test+0xc>

ffffffe000201204 <putc>:
#include "printk.h"
#include "sbi.h"

void putc(char c) {
ffffffe000201204:	fe010113          	addi	sp,sp,-32
ffffffe000201208:	00113c23          	sd	ra,24(sp)
ffffffe00020120c:	00813823          	sd	s0,16(sp)
ffffffe000201210:	02010413          	addi	s0,sp,32
ffffffe000201214:	00050793          	mv	a5,a0
ffffffe000201218:	fef407a3          	sb	a5,-17(s0)
  sbi_ecall(SBI_PUTCHAR, 0, c, 0, 0, 0, 0, 0);
ffffffe00020121c:	fef44603          	lbu	a2,-17(s0)
ffffffe000201220:	00000893          	li	a7,0
ffffffe000201224:	00000813          	li	a6,0
ffffffe000201228:	00000793          	li	a5,0
ffffffe00020122c:	00000713          	li	a4,0
ffffffe000201230:	00000693          	li	a3,0
ffffffe000201234:	00000593          	li	a1,0
ffffffe000201238:	00100513          	li	a0,1
ffffffe00020123c:	9d1ff0ef          	jal	ra,ffffffe000200c0c <sbi_ecall>
}
ffffffe000201240:	00000013          	nop
ffffffe000201244:	01813083          	ld	ra,24(sp)
ffffffe000201248:	01013403          	ld	s0,16(sp)
ffffffe00020124c:	02010113          	addi	sp,sp,32
ffffffe000201250:	00008067          	ret

ffffffe000201254 <vprintfmt>:

static int vprintfmt(void(*putch)(char), const char *fmt, va_list vl) {
ffffffe000201254:	f2010113          	addi	sp,sp,-224
ffffffe000201258:	0c113c23          	sd	ra,216(sp)
ffffffe00020125c:	0c813823          	sd	s0,208(sp)
ffffffe000201260:	0e010413          	addi	s0,sp,224
ffffffe000201264:	f2a43c23          	sd	a0,-200(s0)
ffffffe000201268:	f2b43823          	sd	a1,-208(s0)
ffffffe00020126c:	f2c43423          	sd	a2,-216(s0)
    int in_format = 0, longarg = 0;
ffffffe000201270:	fe042623          	sw	zero,-20(s0)
ffffffe000201274:	fe042423          	sw	zero,-24(s0)
    size_t pos = 0;
ffffffe000201278:	fe043023          	sd	zero,-32(s0)
    for( ; *fmt; fmt++) {
ffffffe00020127c:	48c0006f          	j	ffffffe000201708 <vprintfmt+0x4b4>
        if (in_format) {
ffffffe000201280:	fec42783          	lw	a5,-20(s0)
ffffffe000201284:	0007879b          	sext.w	a5,a5
ffffffe000201288:	42078663          	beqz	a5,ffffffe0002016b4 <vprintfmt+0x460>
            switch(*fmt) {
ffffffe00020128c:	f3043783          	ld	a5,-208(s0)
ffffffe000201290:	0007c783          	lbu	a5,0(a5) # 1000 <_skernel-0xffffffe0001ff000>
ffffffe000201294:	0007879b          	sext.w	a5,a5
ffffffe000201298:	f9d7869b          	addiw	a3,a5,-99
ffffffe00020129c:	0006871b          	sext.w	a4,a3
ffffffe0002012a0:	01500793          	li	a5,21
ffffffe0002012a4:	44e7ea63          	bltu	a5,a4,ffffffe0002016f8 <vprintfmt+0x4a4>
ffffffe0002012a8:	02069793          	slli	a5,a3,0x20
ffffffe0002012ac:	0207d793          	srli	a5,a5,0x20
ffffffe0002012b0:	00279713          	slli	a4,a5,0x2
ffffffe0002012b4:	00001797          	auipc	a5,0x1
ffffffe0002012b8:	e1478793          	addi	a5,a5,-492 # ffffffe0002020c8 <_srodata+0xc8>
ffffffe0002012bc:	00f707b3          	add	a5,a4,a5
ffffffe0002012c0:	0007a783          	lw	a5,0(a5)
ffffffe0002012c4:	0007871b          	sext.w	a4,a5
ffffffe0002012c8:	00001797          	auipc	a5,0x1
ffffffe0002012cc:	e0078793          	addi	a5,a5,-512 # ffffffe0002020c8 <_srodata+0xc8>
ffffffe0002012d0:	00f707b3          	add	a5,a4,a5
ffffffe0002012d4:	00078067          	jr	a5
                case 'l': { 
                    longarg = 1; 
ffffffe0002012d8:	00100793          	li	a5,1
ffffffe0002012dc:	fef42423          	sw	a5,-24(s0)
                    break; 
ffffffe0002012e0:	41c0006f          	j	ffffffe0002016fc <vprintfmt+0x4a8>
                }
                
                case 'x': {
                    long num = longarg ? va_arg(vl, long) : va_arg(vl, int);
ffffffe0002012e4:	fe842783          	lw	a5,-24(s0)
ffffffe0002012e8:	0007879b          	sext.w	a5,a5
ffffffe0002012ec:	00078c63          	beqz	a5,ffffffe000201304 <vprintfmt+0xb0>
ffffffe0002012f0:	f2843783          	ld	a5,-216(s0)
ffffffe0002012f4:	00878713          	addi	a4,a5,8
ffffffe0002012f8:	f2e43423          	sd	a4,-216(s0)
ffffffe0002012fc:	0007b783          	ld	a5,0(a5)
ffffffe000201300:	0140006f          	j	ffffffe000201314 <vprintfmt+0xc0>
ffffffe000201304:	f2843783          	ld	a5,-216(s0)
ffffffe000201308:	00878713          	addi	a4,a5,8
ffffffe00020130c:	f2e43423          	sd	a4,-216(s0)
ffffffe000201310:	0007a783          	lw	a5,0(a5)
ffffffe000201314:	f8f43c23          	sd	a5,-104(s0)

                    int hexdigits = 2 * (longarg ? sizeof(long) : sizeof(int)) - 1;
ffffffe000201318:	fe842783          	lw	a5,-24(s0)
ffffffe00020131c:	0007879b          	sext.w	a5,a5
ffffffe000201320:	00078663          	beqz	a5,ffffffe00020132c <vprintfmt+0xd8>
ffffffe000201324:	00f00793          	li	a5,15
ffffffe000201328:	0080006f          	j	ffffffe000201330 <vprintfmt+0xdc>
ffffffe00020132c:	00700793          	li	a5,7
ffffffe000201330:	f8f42a23          	sw	a5,-108(s0)
                    for(int halfbyte = hexdigits; halfbyte >= 0; halfbyte--) {
ffffffe000201334:	f9442783          	lw	a5,-108(s0)
ffffffe000201338:	fcf42e23          	sw	a5,-36(s0)
ffffffe00020133c:	0840006f          	j	ffffffe0002013c0 <vprintfmt+0x16c>
                        int hex = (num >> (4*halfbyte)) & 0xF;
ffffffe000201340:	fdc42783          	lw	a5,-36(s0)
ffffffe000201344:	0027979b          	slliw	a5,a5,0x2
ffffffe000201348:	0007879b          	sext.w	a5,a5
ffffffe00020134c:	f9843703          	ld	a4,-104(s0)
ffffffe000201350:	40f757b3          	sra	a5,a4,a5
ffffffe000201354:	0007879b          	sext.w	a5,a5
ffffffe000201358:	00f7f793          	andi	a5,a5,15
ffffffe00020135c:	f8f42823          	sw	a5,-112(s0)
                        char hexchar = (hex < 10 ? '0' + hex : 'a' + hex - 10);
ffffffe000201360:	f9042783          	lw	a5,-112(s0)
ffffffe000201364:	0007871b          	sext.w	a4,a5
ffffffe000201368:	00900793          	li	a5,9
ffffffe00020136c:	00e7cc63          	blt	a5,a4,ffffffe000201384 <vprintfmt+0x130>
ffffffe000201370:	f9042783          	lw	a5,-112(s0)
ffffffe000201374:	0ff7f793          	zext.b	a5,a5
ffffffe000201378:	0307879b          	addiw	a5,a5,48
ffffffe00020137c:	0ff7f793          	zext.b	a5,a5
ffffffe000201380:	0140006f          	j	ffffffe000201394 <vprintfmt+0x140>
ffffffe000201384:	f9042783          	lw	a5,-112(s0)
ffffffe000201388:	0ff7f793          	zext.b	a5,a5
ffffffe00020138c:	0577879b          	addiw	a5,a5,87
ffffffe000201390:	0ff7f793          	zext.b	a5,a5
ffffffe000201394:	f8f407a3          	sb	a5,-113(s0)
                        putch(hexchar);
ffffffe000201398:	f8f44703          	lbu	a4,-113(s0)
ffffffe00020139c:	f3843783          	ld	a5,-200(s0)
ffffffe0002013a0:	00070513          	mv	a0,a4
ffffffe0002013a4:	000780e7          	jalr	a5
                        pos++;
ffffffe0002013a8:	fe043783          	ld	a5,-32(s0)
ffffffe0002013ac:	00178793          	addi	a5,a5,1
ffffffe0002013b0:	fef43023          	sd	a5,-32(s0)
                    for(int halfbyte = hexdigits; halfbyte >= 0; halfbyte--) {
ffffffe0002013b4:	fdc42783          	lw	a5,-36(s0)
ffffffe0002013b8:	fff7879b          	addiw	a5,a5,-1
ffffffe0002013bc:	fcf42e23          	sw	a5,-36(s0)
ffffffe0002013c0:	fdc42783          	lw	a5,-36(s0)
ffffffe0002013c4:	0007879b          	sext.w	a5,a5
ffffffe0002013c8:	f607dce3          	bgez	a5,ffffffe000201340 <vprintfmt+0xec>
                    }
                    longarg = 0; in_format = 0; 
ffffffe0002013cc:	fe042423          	sw	zero,-24(s0)
ffffffe0002013d0:	fe042623          	sw	zero,-20(s0)
                    break;
ffffffe0002013d4:	3280006f          	j	ffffffe0002016fc <vprintfmt+0x4a8>
                }
            
                case 'd': {
                    long num = longarg ? va_arg(vl, long) : va_arg(vl, int);
ffffffe0002013d8:	fe842783          	lw	a5,-24(s0)
ffffffe0002013dc:	0007879b          	sext.w	a5,a5
ffffffe0002013e0:	00078c63          	beqz	a5,ffffffe0002013f8 <vprintfmt+0x1a4>
ffffffe0002013e4:	f2843783          	ld	a5,-216(s0)
ffffffe0002013e8:	00878713          	addi	a4,a5,8
ffffffe0002013ec:	f2e43423          	sd	a4,-216(s0)
ffffffe0002013f0:	0007b783          	ld	a5,0(a5)
ffffffe0002013f4:	0140006f          	j	ffffffe000201408 <vprintfmt+0x1b4>
ffffffe0002013f8:	f2843783          	ld	a5,-216(s0)
ffffffe0002013fc:	00878713          	addi	a4,a5,8
ffffffe000201400:	f2e43423          	sd	a4,-216(s0)
ffffffe000201404:	0007a783          	lw	a5,0(a5)
ffffffe000201408:	fcf43823          	sd	a5,-48(s0)
                    if (num < 0) {
ffffffe00020140c:	fd043783          	ld	a5,-48(s0)
ffffffe000201410:	0207d463          	bgez	a5,ffffffe000201438 <vprintfmt+0x1e4>
                        num = -num; putch('-');
ffffffe000201414:	fd043783          	ld	a5,-48(s0)
ffffffe000201418:	40f007b3          	neg	a5,a5
ffffffe00020141c:	fcf43823          	sd	a5,-48(s0)
ffffffe000201420:	f3843783          	ld	a5,-200(s0)
ffffffe000201424:	02d00513          	li	a0,45
ffffffe000201428:	000780e7          	jalr	a5
                        pos++;
ffffffe00020142c:	fe043783          	ld	a5,-32(s0)
ffffffe000201430:	00178793          	addi	a5,a5,1
ffffffe000201434:	fef43023          	sd	a5,-32(s0)
                    }
                    int bits = 0;
ffffffe000201438:	fc042623          	sw	zero,-52(s0)
                    char decchar[25] = {'0', 0};
ffffffe00020143c:	03000793          	li	a5,48
ffffffe000201440:	f6f43023          	sd	a5,-160(s0)
ffffffe000201444:	f6043423          	sd	zero,-152(s0)
ffffffe000201448:	f6043823          	sd	zero,-144(s0)
ffffffe00020144c:	f6040c23          	sb	zero,-136(s0)
                    for (long tmp = num; tmp; bits++) {
ffffffe000201450:	fd043783          	ld	a5,-48(s0)
ffffffe000201454:	fcf43023          	sd	a5,-64(s0)
ffffffe000201458:	0480006f          	j	ffffffe0002014a0 <vprintfmt+0x24c>
                        decchar[bits] = (tmp % 10) + '0';
ffffffe00020145c:	fc043703          	ld	a4,-64(s0)
ffffffe000201460:	00a00793          	li	a5,10
ffffffe000201464:	02f767b3          	rem	a5,a4,a5
ffffffe000201468:	0ff7f793          	zext.b	a5,a5
ffffffe00020146c:	0307879b          	addiw	a5,a5,48
ffffffe000201470:	0ff7f713          	zext.b	a4,a5
ffffffe000201474:	fcc42783          	lw	a5,-52(s0)
ffffffe000201478:	ff078793          	addi	a5,a5,-16
ffffffe00020147c:	008787b3          	add	a5,a5,s0
ffffffe000201480:	f6e78823          	sb	a4,-144(a5)
                        tmp /= 10;
ffffffe000201484:	fc043703          	ld	a4,-64(s0)
ffffffe000201488:	00a00793          	li	a5,10
ffffffe00020148c:	02f747b3          	div	a5,a4,a5
ffffffe000201490:	fcf43023          	sd	a5,-64(s0)
                    for (long tmp = num; tmp; bits++) {
ffffffe000201494:	fcc42783          	lw	a5,-52(s0)
ffffffe000201498:	0017879b          	addiw	a5,a5,1
ffffffe00020149c:	fcf42623          	sw	a5,-52(s0)
ffffffe0002014a0:	fc043783          	ld	a5,-64(s0)
ffffffe0002014a4:	fa079ce3          	bnez	a5,ffffffe00020145c <vprintfmt+0x208>
                    }

                    for (int i = bits; i >= 0; i--) {
ffffffe0002014a8:	fcc42783          	lw	a5,-52(s0)
ffffffe0002014ac:	faf42e23          	sw	a5,-68(s0)
ffffffe0002014b0:	02c0006f          	j	ffffffe0002014dc <vprintfmt+0x288>
                        putch(decchar[i]);
ffffffe0002014b4:	fbc42783          	lw	a5,-68(s0)
ffffffe0002014b8:	ff078793          	addi	a5,a5,-16
ffffffe0002014bc:	008787b3          	add	a5,a5,s0
ffffffe0002014c0:	f707c703          	lbu	a4,-144(a5)
ffffffe0002014c4:	f3843783          	ld	a5,-200(s0)
ffffffe0002014c8:	00070513          	mv	a0,a4
ffffffe0002014cc:	000780e7          	jalr	a5
                    for (int i = bits; i >= 0; i--) {
ffffffe0002014d0:	fbc42783          	lw	a5,-68(s0)
ffffffe0002014d4:	fff7879b          	addiw	a5,a5,-1
ffffffe0002014d8:	faf42e23          	sw	a5,-68(s0)
ffffffe0002014dc:	fbc42783          	lw	a5,-68(s0)
ffffffe0002014e0:	0007879b          	sext.w	a5,a5
ffffffe0002014e4:	fc07d8e3          	bgez	a5,ffffffe0002014b4 <vprintfmt+0x260>
                    }
                    pos += bits + 1;
ffffffe0002014e8:	fcc42783          	lw	a5,-52(s0)
ffffffe0002014ec:	0017879b          	addiw	a5,a5,1
ffffffe0002014f0:	0007879b          	sext.w	a5,a5
ffffffe0002014f4:	00078713          	mv	a4,a5
ffffffe0002014f8:	fe043783          	ld	a5,-32(s0)
ffffffe0002014fc:	00e787b3          	add	a5,a5,a4
ffffffe000201500:	fef43023          	sd	a5,-32(s0)
                    longarg = 0; in_format = 0; 
ffffffe000201504:	fe042423          	sw	zero,-24(s0)
ffffffe000201508:	fe042623          	sw	zero,-20(s0)
                    break;
ffffffe00020150c:	1f00006f          	j	ffffffe0002016fc <vprintfmt+0x4a8>
                }

                case 'u': {
                    unsigned long num = longarg ? va_arg(vl, long) : va_arg(vl, int);
ffffffe000201510:	fe842783          	lw	a5,-24(s0)
ffffffe000201514:	0007879b          	sext.w	a5,a5
ffffffe000201518:	00078c63          	beqz	a5,ffffffe000201530 <vprintfmt+0x2dc>
ffffffe00020151c:	f2843783          	ld	a5,-216(s0)
ffffffe000201520:	00878713          	addi	a4,a5,8
ffffffe000201524:	f2e43423          	sd	a4,-216(s0)
ffffffe000201528:	0007b783          	ld	a5,0(a5)
ffffffe00020152c:	0140006f          	j	ffffffe000201540 <vprintfmt+0x2ec>
ffffffe000201530:	f2843783          	ld	a5,-216(s0)
ffffffe000201534:	00878713          	addi	a4,a5,8
ffffffe000201538:	f2e43423          	sd	a4,-216(s0)
ffffffe00020153c:	0007a783          	lw	a5,0(a5)
ffffffe000201540:	f8f43023          	sd	a5,-128(s0)
                    int bits = 0;
ffffffe000201544:	fa042c23          	sw	zero,-72(s0)
                    char decchar[25] = {'0', 0};
ffffffe000201548:	03000793          	li	a5,48
ffffffe00020154c:	f4f43023          	sd	a5,-192(s0)
ffffffe000201550:	f4043423          	sd	zero,-184(s0)
ffffffe000201554:	f4043823          	sd	zero,-176(s0)
ffffffe000201558:	f4040c23          	sb	zero,-168(s0)
                    for (long tmp = num; tmp; bits++) {
ffffffe00020155c:	f8043783          	ld	a5,-128(s0)
ffffffe000201560:	faf43823          	sd	a5,-80(s0)
ffffffe000201564:	0480006f          	j	ffffffe0002015ac <vprintfmt+0x358>
                        decchar[bits] = (tmp % 10) + '0';
ffffffe000201568:	fb043703          	ld	a4,-80(s0)
ffffffe00020156c:	00a00793          	li	a5,10
ffffffe000201570:	02f767b3          	rem	a5,a4,a5
ffffffe000201574:	0ff7f793          	zext.b	a5,a5
ffffffe000201578:	0307879b          	addiw	a5,a5,48
ffffffe00020157c:	0ff7f713          	zext.b	a4,a5
ffffffe000201580:	fb842783          	lw	a5,-72(s0)
ffffffe000201584:	ff078793          	addi	a5,a5,-16
ffffffe000201588:	008787b3          	add	a5,a5,s0
ffffffe00020158c:	f4e78823          	sb	a4,-176(a5)
                        tmp /= 10;
ffffffe000201590:	fb043703          	ld	a4,-80(s0)
ffffffe000201594:	00a00793          	li	a5,10
ffffffe000201598:	02f747b3          	div	a5,a4,a5
ffffffe00020159c:	faf43823          	sd	a5,-80(s0)
                    for (long tmp = num; tmp; bits++) {
ffffffe0002015a0:	fb842783          	lw	a5,-72(s0)
ffffffe0002015a4:	0017879b          	addiw	a5,a5,1
ffffffe0002015a8:	faf42c23          	sw	a5,-72(s0)
ffffffe0002015ac:	fb043783          	ld	a5,-80(s0)
ffffffe0002015b0:	fa079ce3          	bnez	a5,ffffffe000201568 <vprintfmt+0x314>
                    }

                    for (int i = bits; i >= 0; i--) {
ffffffe0002015b4:	fb842783          	lw	a5,-72(s0)
ffffffe0002015b8:	faf42623          	sw	a5,-84(s0)
ffffffe0002015bc:	02c0006f          	j	ffffffe0002015e8 <vprintfmt+0x394>
                        putch(decchar[i]);
ffffffe0002015c0:	fac42783          	lw	a5,-84(s0)
ffffffe0002015c4:	ff078793          	addi	a5,a5,-16
ffffffe0002015c8:	008787b3          	add	a5,a5,s0
ffffffe0002015cc:	f507c703          	lbu	a4,-176(a5)
ffffffe0002015d0:	f3843783          	ld	a5,-200(s0)
ffffffe0002015d4:	00070513          	mv	a0,a4
ffffffe0002015d8:	000780e7          	jalr	a5
                    for (int i = bits; i >= 0; i--) {
ffffffe0002015dc:	fac42783          	lw	a5,-84(s0)
ffffffe0002015e0:	fff7879b          	addiw	a5,a5,-1
ffffffe0002015e4:	faf42623          	sw	a5,-84(s0)
ffffffe0002015e8:	fac42783          	lw	a5,-84(s0)
ffffffe0002015ec:	0007879b          	sext.w	a5,a5
ffffffe0002015f0:	fc07d8e3          	bgez	a5,ffffffe0002015c0 <vprintfmt+0x36c>
                    }
                    pos += bits + 1;
ffffffe0002015f4:	fb842783          	lw	a5,-72(s0)
ffffffe0002015f8:	0017879b          	addiw	a5,a5,1
ffffffe0002015fc:	0007879b          	sext.w	a5,a5
ffffffe000201600:	00078713          	mv	a4,a5
ffffffe000201604:	fe043783          	ld	a5,-32(s0)
ffffffe000201608:	00e787b3          	add	a5,a5,a4
ffffffe00020160c:	fef43023          	sd	a5,-32(s0)
                    longarg = 0; in_format = 0; 
ffffffe000201610:	fe042423          	sw	zero,-24(s0)
ffffffe000201614:	fe042623          	sw	zero,-20(s0)
                    break;
ffffffe000201618:	0e40006f          	j	ffffffe0002016fc <vprintfmt+0x4a8>
                }

                case 's': {
                    const char* str = va_arg(vl, const char*);
ffffffe00020161c:	f2843783          	ld	a5,-216(s0)
ffffffe000201620:	00878713          	addi	a4,a5,8
ffffffe000201624:	f2e43423          	sd	a4,-216(s0)
ffffffe000201628:	0007b783          	ld	a5,0(a5)
ffffffe00020162c:	faf43023          	sd	a5,-96(s0)
                    while (*str) {
ffffffe000201630:	0300006f          	j	ffffffe000201660 <vprintfmt+0x40c>
                        putch(*str);
ffffffe000201634:	fa043783          	ld	a5,-96(s0)
ffffffe000201638:	0007c703          	lbu	a4,0(a5)
ffffffe00020163c:	f3843783          	ld	a5,-200(s0)
ffffffe000201640:	00070513          	mv	a0,a4
ffffffe000201644:	000780e7          	jalr	a5
                        pos++; 
ffffffe000201648:	fe043783          	ld	a5,-32(s0)
ffffffe00020164c:	00178793          	addi	a5,a5,1
ffffffe000201650:	fef43023          	sd	a5,-32(s0)
                        str++;
ffffffe000201654:	fa043783          	ld	a5,-96(s0)
ffffffe000201658:	00178793          	addi	a5,a5,1
ffffffe00020165c:	faf43023          	sd	a5,-96(s0)
                    while (*str) {
ffffffe000201660:	fa043783          	ld	a5,-96(s0)
ffffffe000201664:	0007c783          	lbu	a5,0(a5)
ffffffe000201668:	fc0796e3          	bnez	a5,ffffffe000201634 <vprintfmt+0x3e0>
                    }
                    longarg = 0; in_format = 0; 
ffffffe00020166c:	fe042423          	sw	zero,-24(s0)
ffffffe000201670:	fe042623          	sw	zero,-20(s0)
                    break;
ffffffe000201674:	0880006f          	j	ffffffe0002016fc <vprintfmt+0x4a8>
                }

                case 'c': {
                    char ch = (char)va_arg(vl,int);
ffffffe000201678:	f2843783          	ld	a5,-216(s0)
ffffffe00020167c:	00878713          	addi	a4,a5,8
ffffffe000201680:	f2e43423          	sd	a4,-216(s0)
ffffffe000201684:	0007a783          	lw	a5,0(a5)
ffffffe000201688:	f6f40fa3          	sb	a5,-129(s0)
                    putch(ch);
ffffffe00020168c:	f7f44703          	lbu	a4,-129(s0)
ffffffe000201690:	f3843783          	ld	a5,-200(s0)
ffffffe000201694:	00070513          	mv	a0,a4
ffffffe000201698:	000780e7          	jalr	a5
                    pos++;
ffffffe00020169c:	fe043783          	ld	a5,-32(s0)
ffffffe0002016a0:	00178793          	addi	a5,a5,1
ffffffe0002016a4:	fef43023          	sd	a5,-32(s0)
                    longarg = 0; in_format = 0; 
ffffffe0002016a8:	fe042423          	sw	zero,-24(s0)
ffffffe0002016ac:	fe042623          	sw	zero,-20(s0)
                    break;
ffffffe0002016b0:	04c0006f          	j	ffffffe0002016fc <vprintfmt+0x4a8>
                }
                default:
                    break;
            }
        }
        else if(*fmt == '%') {
ffffffe0002016b4:	f3043783          	ld	a5,-208(s0)
ffffffe0002016b8:	0007c783          	lbu	a5,0(a5)
ffffffe0002016bc:	00078713          	mv	a4,a5
ffffffe0002016c0:	02500793          	li	a5,37
ffffffe0002016c4:	00f71863          	bne	a4,a5,ffffffe0002016d4 <vprintfmt+0x480>
          in_format = 1;
ffffffe0002016c8:	00100793          	li	a5,1
ffffffe0002016cc:	fef42623          	sw	a5,-20(s0)
ffffffe0002016d0:	02c0006f          	j	ffffffe0002016fc <vprintfmt+0x4a8>
        }
        else {                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
            putch(*fmt);
ffffffe0002016d4:	f3043783          	ld	a5,-208(s0)
ffffffe0002016d8:	0007c703          	lbu	a4,0(a5)
ffffffe0002016dc:	f3843783          	ld	a5,-200(s0)
ffffffe0002016e0:	00070513          	mv	a0,a4
ffffffe0002016e4:	000780e7          	jalr	a5
            pos++;
ffffffe0002016e8:	fe043783          	ld	a5,-32(s0)
ffffffe0002016ec:	00178793          	addi	a5,a5,1
ffffffe0002016f0:	fef43023          	sd	a5,-32(s0)
ffffffe0002016f4:	0080006f          	j	ffffffe0002016fc <vprintfmt+0x4a8>
                    break;
ffffffe0002016f8:	00000013          	nop
    for( ; *fmt; fmt++) {
ffffffe0002016fc:	f3043783          	ld	a5,-208(s0)
ffffffe000201700:	00178793          	addi	a5,a5,1
ffffffe000201704:	f2f43823          	sd	a5,-208(s0)
ffffffe000201708:	f3043783          	ld	a5,-208(s0)
ffffffe00020170c:	0007c783          	lbu	a5,0(a5)
ffffffe000201710:	b60798e3          	bnez	a5,ffffffe000201280 <vprintfmt+0x2c>
        }
    }
    return pos;
ffffffe000201714:	fe043783          	ld	a5,-32(s0)
ffffffe000201718:	0007879b          	sext.w	a5,a5
}
ffffffe00020171c:	00078513          	mv	a0,a5
ffffffe000201720:	0d813083          	ld	ra,216(sp)
ffffffe000201724:	0d013403          	ld	s0,208(sp)
ffffffe000201728:	0e010113          	addi	sp,sp,224
ffffffe00020172c:	00008067          	ret

ffffffe000201730 <printk>:



int printk(const char* s, ...) {
ffffffe000201730:	f9010113          	addi	sp,sp,-112
ffffffe000201734:	02113423          	sd	ra,40(sp)
ffffffe000201738:	02813023          	sd	s0,32(sp)
ffffffe00020173c:	03010413          	addi	s0,sp,48
ffffffe000201740:	fca43c23          	sd	a0,-40(s0)
ffffffe000201744:	00b43423          	sd	a1,8(s0)
ffffffe000201748:	00c43823          	sd	a2,16(s0)
ffffffe00020174c:	00d43c23          	sd	a3,24(s0)
ffffffe000201750:	02e43023          	sd	a4,32(s0)
ffffffe000201754:	02f43423          	sd	a5,40(s0)
ffffffe000201758:	03043823          	sd	a6,48(s0)
ffffffe00020175c:	03143c23          	sd	a7,56(s0)
    int res = 0;
ffffffe000201760:	fe042623          	sw	zero,-20(s0)
    va_list vl;
    va_start(vl, s);
ffffffe000201764:	04040793          	addi	a5,s0,64
ffffffe000201768:	fcf43823          	sd	a5,-48(s0)
ffffffe00020176c:	fd043783          	ld	a5,-48(s0)
ffffffe000201770:	fc878793          	addi	a5,a5,-56
ffffffe000201774:	fef43023          	sd	a5,-32(s0)
    res = vprintfmt(putc, s, vl);
ffffffe000201778:	fe043783          	ld	a5,-32(s0)
ffffffe00020177c:	00078613          	mv	a2,a5
ffffffe000201780:	fd843583          	ld	a1,-40(s0)
ffffffe000201784:	00000517          	auipc	a0,0x0
ffffffe000201788:	a8050513          	addi	a0,a0,-1408 # ffffffe000201204 <putc>
ffffffe00020178c:	ac9ff0ef          	jal	ra,ffffffe000201254 <vprintfmt>
ffffffe000201790:	00050793          	mv	a5,a0
ffffffe000201794:	fef42623          	sw	a5,-20(s0)
    va_end(vl);
    return res;
ffffffe000201798:	fec42783          	lw	a5,-20(s0)
}
ffffffe00020179c:	00078513          	mv	a0,a5
ffffffe0002017a0:	02813083          	ld	ra,40(sp)
ffffffe0002017a4:	02013403          	ld	s0,32(sp)
ffffffe0002017a8:	07010113          	addi	sp,sp,112
ffffffe0002017ac:	00008067          	ret

ffffffe0002017b0 <rand>:

int initialize = 0;
int r[1000];
int t = 0;

uint64 rand() {
ffffffe0002017b0:	fe010113          	addi	sp,sp,-32
ffffffe0002017b4:	00813c23          	sd	s0,24(sp)
ffffffe0002017b8:	02010413          	addi	s0,sp,32
    int i;

    if (initialize == 0) {
ffffffe0002017bc:	00003797          	auipc	a5,0x3
ffffffe0002017c0:	86078793          	addi	a5,a5,-1952 # ffffffe00020401c <initialize>
ffffffe0002017c4:	0007a783          	lw	a5,0(a5)
ffffffe0002017c8:	1e079463          	bnez	a5,ffffffe0002019b0 <rand+0x200>
        r[0] = SEED;
ffffffe0002017cc:	00006797          	auipc	a5,0x6
ffffffe0002017d0:	83478793          	addi	a5,a5,-1996 # ffffffe000207000 <r>
ffffffe0002017d4:	00d00713          	li	a4,13
ffffffe0002017d8:	00e7a023          	sw	a4,0(a5)
        for (i = 1; i < 31; i++) {
ffffffe0002017dc:	00100793          	li	a5,1
ffffffe0002017e0:	fef42623          	sw	a5,-20(s0)
ffffffe0002017e4:	0c40006f          	j	ffffffe0002018a8 <rand+0xf8>
            r[i] = (16807LL * r[i - 1]) % 2147483647;
ffffffe0002017e8:	fec42783          	lw	a5,-20(s0)
ffffffe0002017ec:	fff7879b          	addiw	a5,a5,-1
ffffffe0002017f0:	0007879b          	sext.w	a5,a5
ffffffe0002017f4:	00006717          	auipc	a4,0x6
ffffffe0002017f8:	80c70713          	addi	a4,a4,-2036 # ffffffe000207000 <r>
ffffffe0002017fc:	00279793          	slli	a5,a5,0x2
ffffffe000201800:	00f707b3          	add	a5,a4,a5
ffffffe000201804:	0007a783          	lw	a5,0(a5)
ffffffe000201808:	00078713          	mv	a4,a5
ffffffe00020180c:	000047b7          	lui	a5,0x4
ffffffe000201810:	1a778793          	addi	a5,a5,423 # 41a7 <_skernel-0xffffffe0001fbe59>
ffffffe000201814:	02f70733          	mul	a4,a4,a5
ffffffe000201818:	800007b7          	lui	a5,0x80000
ffffffe00020181c:	fff7c793          	not	a5,a5
ffffffe000201820:	02f767b3          	rem	a5,a4,a5
ffffffe000201824:	0007871b          	sext.w	a4,a5
ffffffe000201828:	00005697          	auipc	a3,0x5
ffffffe00020182c:	7d868693          	addi	a3,a3,2008 # ffffffe000207000 <r>
ffffffe000201830:	fec42783          	lw	a5,-20(s0)
ffffffe000201834:	00279793          	slli	a5,a5,0x2
ffffffe000201838:	00f687b3          	add	a5,a3,a5
ffffffe00020183c:	00e7a023          	sw	a4,0(a5) # ffffffff80000000 <_estack+0x1f7fdf6000>
            if (r[i] < 0) {
ffffffe000201840:	00005717          	auipc	a4,0x5
ffffffe000201844:	7c070713          	addi	a4,a4,1984 # ffffffe000207000 <r>
ffffffe000201848:	fec42783          	lw	a5,-20(s0)
ffffffe00020184c:	00279793          	slli	a5,a5,0x2
ffffffe000201850:	00f707b3          	add	a5,a4,a5
ffffffe000201854:	0007a783          	lw	a5,0(a5)
ffffffe000201858:	0407d263          	bgez	a5,ffffffe00020189c <rand+0xec>
                r[i] += 2147483647;
ffffffe00020185c:	00005717          	auipc	a4,0x5
ffffffe000201860:	7a470713          	addi	a4,a4,1956 # ffffffe000207000 <r>
ffffffe000201864:	fec42783          	lw	a5,-20(s0)
ffffffe000201868:	00279793          	slli	a5,a5,0x2
ffffffe00020186c:	00f707b3          	add	a5,a4,a5
ffffffe000201870:	0007a703          	lw	a4,0(a5)
ffffffe000201874:	800007b7          	lui	a5,0x80000
ffffffe000201878:	fff7c793          	not	a5,a5
ffffffe00020187c:	00f707bb          	addw	a5,a4,a5
ffffffe000201880:	0007871b          	sext.w	a4,a5
ffffffe000201884:	00005697          	auipc	a3,0x5
ffffffe000201888:	77c68693          	addi	a3,a3,1916 # ffffffe000207000 <r>
ffffffe00020188c:	fec42783          	lw	a5,-20(s0)
ffffffe000201890:	00279793          	slli	a5,a5,0x2
ffffffe000201894:	00f687b3          	add	a5,a3,a5
ffffffe000201898:	00e7a023          	sw	a4,0(a5) # ffffffff80000000 <_estack+0x1f7fdf6000>
        for (i = 1; i < 31; i++) {
ffffffe00020189c:	fec42783          	lw	a5,-20(s0)
ffffffe0002018a0:	0017879b          	addiw	a5,a5,1
ffffffe0002018a4:	fef42623          	sw	a5,-20(s0)
ffffffe0002018a8:	fec42783          	lw	a5,-20(s0)
ffffffe0002018ac:	0007871b          	sext.w	a4,a5
ffffffe0002018b0:	01e00793          	li	a5,30
ffffffe0002018b4:	f2e7dae3          	bge	a5,a4,ffffffe0002017e8 <rand+0x38>
            }
        }
        for (i = 31; i < 34; i++) {
ffffffe0002018b8:	01f00793          	li	a5,31
ffffffe0002018bc:	fef42623          	sw	a5,-20(s0)
ffffffe0002018c0:	0480006f          	j	ffffffe000201908 <rand+0x158>
            r[i] = r[i - 31];
ffffffe0002018c4:	fec42783          	lw	a5,-20(s0)
ffffffe0002018c8:	fe17879b          	addiw	a5,a5,-31
ffffffe0002018cc:	0007879b          	sext.w	a5,a5
ffffffe0002018d0:	00005717          	auipc	a4,0x5
ffffffe0002018d4:	73070713          	addi	a4,a4,1840 # ffffffe000207000 <r>
ffffffe0002018d8:	00279793          	slli	a5,a5,0x2
ffffffe0002018dc:	00f707b3          	add	a5,a4,a5
ffffffe0002018e0:	0007a703          	lw	a4,0(a5)
ffffffe0002018e4:	00005697          	auipc	a3,0x5
ffffffe0002018e8:	71c68693          	addi	a3,a3,1820 # ffffffe000207000 <r>
ffffffe0002018ec:	fec42783          	lw	a5,-20(s0)
ffffffe0002018f0:	00279793          	slli	a5,a5,0x2
ffffffe0002018f4:	00f687b3          	add	a5,a3,a5
ffffffe0002018f8:	00e7a023          	sw	a4,0(a5)
        for (i = 31; i < 34; i++) {
ffffffe0002018fc:	fec42783          	lw	a5,-20(s0)
ffffffe000201900:	0017879b          	addiw	a5,a5,1
ffffffe000201904:	fef42623          	sw	a5,-20(s0)
ffffffe000201908:	fec42783          	lw	a5,-20(s0)
ffffffe00020190c:	0007871b          	sext.w	a4,a5
ffffffe000201910:	02100793          	li	a5,33
ffffffe000201914:	fae7d8e3          	bge	a5,a4,ffffffe0002018c4 <rand+0x114>
        }
        for (i = 34; i < 344; i++) {
ffffffe000201918:	02200793          	li	a5,34
ffffffe00020191c:	fef42623          	sw	a5,-20(s0)
ffffffe000201920:	0700006f          	j	ffffffe000201990 <rand+0x1e0>
            r[i] = r[i - 31] + r[i - 3];
ffffffe000201924:	fec42783          	lw	a5,-20(s0)
ffffffe000201928:	fe17879b          	addiw	a5,a5,-31
ffffffe00020192c:	0007879b          	sext.w	a5,a5
ffffffe000201930:	00005717          	auipc	a4,0x5
ffffffe000201934:	6d070713          	addi	a4,a4,1744 # ffffffe000207000 <r>
ffffffe000201938:	00279793          	slli	a5,a5,0x2
ffffffe00020193c:	00f707b3          	add	a5,a4,a5
ffffffe000201940:	0007a703          	lw	a4,0(a5)
ffffffe000201944:	fec42783          	lw	a5,-20(s0)
ffffffe000201948:	ffd7879b          	addiw	a5,a5,-3
ffffffe00020194c:	0007879b          	sext.w	a5,a5
ffffffe000201950:	00005697          	auipc	a3,0x5
ffffffe000201954:	6b068693          	addi	a3,a3,1712 # ffffffe000207000 <r>
ffffffe000201958:	00279793          	slli	a5,a5,0x2
ffffffe00020195c:	00f687b3          	add	a5,a3,a5
ffffffe000201960:	0007a783          	lw	a5,0(a5)
ffffffe000201964:	00f707bb          	addw	a5,a4,a5
ffffffe000201968:	0007871b          	sext.w	a4,a5
ffffffe00020196c:	00005697          	auipc	a3,0x5
ffffffe000201970:	69468693          	addi	a3,a3,1684 # ffffffe000207000 <r>
ffffffe000201974:	fec42783          	lw	a5,-20(s0)
ffffffe000201978:	00279793          	slli	a5,a5,0x2
ffffffe00020197c:	00f687b3          	add	a5,a3,a5
ffffffe000201980:	00e7a023          	sw	a4,0(a5)
        for (i = 34; i < 344; i++) {
ffffffe000201984:	fec42783          	lw	a5,-20(s0)
ffffffe000201988:	0017879b          	addiw	a5,a5,1
ffffffe00020198c:	fef42623          	sw	a5,-20(s0)
ffffffe000201990:	fec42783          	lw	a5,-20(s0)
ffffffe000201994:	0007871b          	sext.w	a4,a5
ffffffe000201998:	15700793          	li	a5,343
ffffffe00020199c:	f8e7d4e3          	bge	a5,a4,ffffffe000201924 <rand+0x174>
        }

		initialize = 1;
ffffffe0002019a0:	00002797          	auipc	a5,0x2
ffffffe0002019a4:	67c78793          	addi	a5,a5,1660 # ffffffe00020401c <initialize>
ffffffe0002019a8:	00100713          	li	a4,1
ffffffe0002019ac:	00e7a023          	sw	a4,0(a5)
    }

	t = t % 656;
ffffffe0002019b0:	00002797          	auipc	a5,0x2
ffffffe0002019b4:	67078793          	addi	a5,a5,1648 # ffffffe000204020 <t>
ffffffe0002019b8:	0007a783          	lw	a5,0(a5)
ffffffe0002019bc:	00078713          	mv	a4,a5
ffffffe0002019c0:	29000793          	li	a5,656
ffffffe0002019c4:	02f767bb          	remw	a5,a4,a5
ffffffe0002019c8:	0007871b          	sext.w	a4,a5
ffffffe0002019cc:	00002797          	auipc	a5,0x2
ffffffe0002019d0:	65478793          	addi	a5,a5,1620 # ffffffe000204020 <t>
ffffffe0002019d4:	00e7a023          	sw	a4,0(a5)

    r[t + 344] = r[t + 344 - 31] + r[t + 344 - 3];
ffffffe0002019d8:	00002797          	auipc	a5,0x2
ffffffe0002019dc:	64878793          	addi	a5,a5,1608 # ffffffe000204020 <t>
ffffffe0002019e0:	0007a783          	lw	a5,0(a5)
ffffffe0002019e4:	1397879b          	addiw	a5,a5,313
ffffffe0002019e8:	0007879b          	sext.w	a5,a5
ffffffe0002019ec:	00005717          	auipc	a4,0x5
ffffffe0002019f0:	61470713          	addi	a4,a4,1556 # ffffffe000207000 <r>
ffffffe0002019f4:	00279793          	slli	a5,a5,0x2
ffffffe0002019f8:	00f707b3          	add	a5,a4,a5
ffffffe0002019fc:	0007a683          	lw	a3,0(a5)
ffffffe000201a00:	00002797          	auipc	a5,0x2
ffffffe000201a04:	62078793          	addi	a5,a5,1568 # ffffffe000204020 <t>
ffffffe000201a08:	0007a783          	lw	a5,0(a5)
ffffffe000201a0c:	1557879b          	addiw	a5,a5,341
ffffffe000201a10:	0007879b          	sext.w	a5,a5
ffffffe000201a14:	00005717          	auipc	a4,0x5
ffffffe000201a18:	5ec70713          	addi	a4,a4,1516 # ffffffe000207000 <r>
ffffffe000201a1c:	00279793          	slli	a5,a5,0x2
ffffffe000201a20:	00f707b3          	add	a5,a4,a5
ffffffe000201a24:	0007a703          	lw	a4,0(a5)
ffffffe000201a28:	00002797          	auipc	a5,0x2
ffffffe000201a2c:	5f878793          	addi	a5,a5,1528 # ffffffe000204020 <t>
ffffffe000201a30:	0007a783          	lw	a5,0(a5)
ffffffe000201a34:	1587879b          	addiw	a5,a5,344
ffffffe000201a38:	0007879b          	sext.w	a5,a5
ffffffe000201a3c:	00e6873b          	addw	a4,a3,a4
ffffffe000201a40:	0007071b          	sext.w	a4,a4
ffffffe000201a44:	00005697          	auipc	a3,0x5
ffffffe000201a48:	5bc68693          	addi	a3,a3,1468 # ffffffe000207000 <r>
ffffffe000201a4c:	00279793          	slli	a5,a5,0x2
ffffffe000201a50:	00f687b3          	add	a5,a3,a5
ffffffe000201a54:	00e7a023          	sw	a4,0(a5)
    
	t++;
ffffffe000201a58:	00002797          	auipc	a5,0x2
ffffffe000201a5c:	5c878793          	addi	a5,a5,1480 # ffffffe000204020 <t>
ffffffe000201a60:	0007a783          	lw	a5,0(a5)
ffffffe000201a64:	0017879b          	addiw	a5,a5,1
ffffffe000201a68:	0007871b          	sext.w	a4,a5
ffffffe000201a6c:	00002797          	auipc	a5,0x2
ffffffe000201a70:	5b478793          	addi	a5,a5,1460 # ffffffe000204020 <t>
ffffffe000201a74:	00e7a023          	sw	a4,0(a5)

    return (uint64)r[t - 1 + 344];
ffffffe000201a78:	00002797          	auipc	a5,0x2
ffffffe000201a7c:	5a878793          	addi	a5,a5,1448 # ffffffe000204020 <t>
ffffffe000201a80:	0007a783          	lw	a5,0(a5)
ffffffe000201a84:	1577879b          	addiw	a5,a5,343
ffffffe000201a88:	0007879b          	sext.w	a5,a5
ffffffe000201a8c:	00005717          	auipc	a4,0x5
ffffffe000201a90:	57470713          	addi	a4,a4,1396 # ffffffe000207000 <r>
ffffffe000201a94:	00279793          	slli	a5,a5,0x2
ffffffe000201a98:	00f707b3          	add	a5,a4,a5
ffffffe000201a9c:	0007a783          	lw	a5,0(a5)
}
ffffffe000201aa0:	00078513          	mv	a0,a5
ffffffe000201aa4:	01813403          	ld	s0,24(sp)
ffffffe000201aa8:	02010113          	addi	sp,sp,32
ffffffe000201aac:	00008067          	ret

ffffffe000201ab0 <memset>:
#include "string.h"

void *memset(void *dst, int c, uint64 n) {
ffffffe000201ab0:	fc010113          	addi	sp,sp,-64
ffffffe000201ab4:	02813c23          	sd	s0,56(sp)
ffffffe000201ab8:	04010413          	addi	s0,sp,64
ffffffe000201abc:	fca43c23          	sd	a0,-40(s0)
ffffffe000201ac0:	00058793          	mv	a5,a1
ffffffe000201ac4:	fcc43423          	sd	a2,-56(s0)
ffffffe000201ac8:	fcf42a23          	sw	a5,-44(s0)
    char *cdst = (char *)dst;
ffffffe000201acc:	fd843783          	ld	a5,-40(s0)
ffffffe000201ad0:	fef43023          	sd	a5,-32(s0)
    for (uint64 i = 0; i < n; ++i)
ffffffe000201ad4:	fe043423          	sd	zero,-24(s0)
ffffffe000201ad8:	0280006f          	j	ffffffe000201b00 <memset+0x50>
        cdst[i] = c;
ffffffe000201adc:	fe043703          	ld	a4,-32(s0)
ffffffe000201ae0:	fe843783          	ld	a5,-24(s0)
ffffffe000201ae4:	00f707b3          	add	a5,a4,a5
ffffffe000201ae8:	fd442703          	lw	a4,-44(s0)
ffffffe000201aec:	0ff77713          	zext.b	a4,a4
ffffffe000201af0:	00e78023          	sb	a4,0(a5)
    for (uint64 i = 0; i < n; ++i)
ffffffe000201af4:	fe843783          	ld	a5,-24(s0)
ffffffe000201af8:	00178793          	addi	a5,a5,1
ffffffe000201afc:	fef43423          	sd	a5,-24(s0)
ffffffe000201b00:	fe843703          	ld	a4,-24(s0)
ffffffe000201b04:	fc843783          	ld	a5,-56(s0)
ffffffe000201b08:	fcf76ae3          	bltu	a4,a5,ffffffe000201adc <memset+0x2c>

    return dst;
ffffffe000201b0c:	fd843783          	ld	a5,-40(s0)
}
ffffffe000201b10:	00078513          	mv	a0,a5
ffffffe000201b14:	03813403          	ld	s0,56(sp)
ffffffe000201b18:	04010113          	addi	sp,sp,64
ffffffe000201b1c:	00008067          	ret
